-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Fix CombiningFirehose compatibility #10264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
356cd43
Fix CombiningFirehose
f62775b
Merge branch 'master' of https://github.com/druid-io/druid into fix_c…
03b56bc
Add integration test
fcdb6af
Fix path
8d3f718
Add full datasource name
10ab129
Fix input location
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
...sts/src/test/java/org/apache/druid/tests/indexer/ITCombiningFirehoseFactoryIndexTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.tests.indexer; | ||
|
|
||
| import org.apache.druid.java.util.common.StringUtils; | ||
| import org.apache.druid.testing.guice.DruidTestModuleFactory; | ||
| import org.apache.druid.tests.TestNGGroup; | ||
| import org.testng.annotations.Guice; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.io.Closeable; | ||
| import java.util.function.Function; | ||
|
|
||
| @Test(groups = {TestNGGroup.BATCH_INDEX, TestNGGroup.QUICKSTART_COMPATIBLE}) | ||
| @Guice(moduleFactory = DruidTestModuleFactory.class) | ||
| public class ITCombiningFirehoseFactoryIndexTest extends AbstractITBatchIndexTest | ||
| { | ||
| private static final String INDEX_TASK = "/indexer/wikipedia_index_task.json"; | ||
| private static final String INDEX_QUERIES_RESOURCE = "/indexer/wikipedia_index_queries.json"; | ||
| private static final String INDEX_DATASOURCE = "wikipedia_index_test"; | ||
|
|
||
| private static final String COMBINING_INDEX_TASK = "/indexer/wikipedia_combining_firehose_index_task.json"; | ||
| private static final String COMBINING_QUERIES_RESOURCE = "/indexer/wikipedia_combining_firehose_index_queries.json"; | ||
| private static final String COMBINING_INDEX_DATASOURCE = "wikipedia_comb_index_test"; | ||
|
|
||
| @Test | ||
| public void testIndexData() throws Exception | ||
| { | ||
| try ( | ||
| final Closeable ignored1 = unloader(INDEX_DATASOURCE + config.getExtraDatasourceNameSuffix()); | ||
| final Closeable ignored2 = unloader(COMBINING_INDEX_DATASOURCE + config.getExtraDatasourceNameSuffix()); | ||
| ) { | ||
| final Function<String, String> combiningFirehoseSpecTransform = spec -> { | ||
| try { | ||
| return StringUtils.replace( | ||
| spec, | ||
| "%%COMBINING_DATASOURCE%%", | ||
| INDEX_DATASOURCE + config.getExtraDatasourceNameSuffix() | ||
| ); | ||
| } | ||
| catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| }; | ||
| doIndexTest( | ||
| INDEX_DATASOURCE, | ||
| INDEX_TASK, | ||
| INDEX_QUERIES_RESOURCE, | ||
| false, | ||
| true, | ||
| true | ||
| ); | ||
| doIndexTest( | ||
| COMBINING_INDEX_DATASOURCE, | ||
| COMBINING_INDEX_TASK, | ||
| combiningFirehoseSpecTransform, | ||
| COMBINING_QUERIES_RESOURCE, | ||
| false, | ||
| true, | ||
| true | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| } |
141 changes: 141 additions & 0 deletions
141
integration-tests/src/test/resources/indexer/wikipedia_combining_firehose_index_queries.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| [ | ||
| { | ||
| "description": "timeseries, 1 agg, all", | ||
| "query": { | ||
| "queryType": "timeBoundary", | ||
| "dataSource": "%%DATASOURCE%%" | ||
| }, | ||
| "expectedResults": [ | ||
| { | ||
| "timestamp": "2013-08-31T01:02:33.000Z", | ||
| "result": { | ||
| "minTime": "2013-08-31T01:02:33.000Z", | ||
| "maxTime": "2013-09-01T18:22:39.000Z" | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "description": "timeseries, datasketch aggs, all", | ||
| "query": { | ||
| "queryType": "timeseries", | ||
| "dataSource": "%%DATASOURCE%%", | ||
| "granularity": "day", | ||
| "intervals": [ | ||
| "2013-09-01T00:00/2013-09-02T00:00" | ||
| ], | ||
| "filter": null, | ||
| "aggregations": [ | ||
| { | ||
| "type": "HLLSketchMerge", | ||
| "name": "approxCountHLL", | ||
| "fieldName": "HLLSketchBuild", | ||
| "lgK": 12, | ||
| "tgtHllType": "HLL_4", | ||
| "round": true | ||
| }, | ||
| { | ||
| "type": "thetaSketch", | ||
| "name": "approxCountTheta", | ||
| "fieldName": "thetaSketch", | ||
| "size": 16384, | ||
| "shouldFinalize": true, | ||
| "isInputThetaSketch": false, | ||
| "errorBoundsStdDev": null | ||
| }, | ||
| { | ||
| "type": "quantilesDoublesSketch", | ||
| "name": "quantilesSketch", | ||
| "fieldName": "quantilesDoublesSketch", | ||
| "k": 128 | ||
| } | ||
| ] | ||
| }, | ||
| "expectedResults": [ | ||
| { | ||
| "timestamp": "2013-09-01T00:00:00.000Z", | ||
| "result": { | ||
| "quantilesSketch": 6, | ||
| "approxCountTheta": 6.0, | ||
| "approxCountHLL": 6 | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "description": "having spec on post aggregation", | ||
| "query": { | ||
| "queryType": "groupBy", | ||
| "dataSource": "%%DATASOURCE%%", | ||
| "granularity": "day", | ||
| "dimensions": [ | ||
| "page" | ||
| ], | ||
| "filter": { | ||
| "type": "selector", | ||
| "dimension": "language", | ||
| "value": "zh" | ||
| }, | ||
| "aggregations": [ | ||
| { | ||
| "type": "count", | ||
| "name": "rows" | ||
| }, | ||
| { | ||
| "type": "longSum", | ||
| "fieldName": "added", | ||
| "name": "added_count" | ||
| } | ||
| ], | ||
| "postAggregations": [ | ||
| { | ||
| "type": "arithmetic", | ||
| "name": "added_count_times_ten", | ||
| "fn": "*", | ||
| "fields": [ | ||
| { | ||
| "type": "fieldAccess", | ||
| "name": "added_count", | ||
| "fieldName": "added_count" | ||
| }, | ||
| { | ||
| "type": "constant", | ||
| "name": "const", | ||
| "value": 10 | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "having": { | ||
| "type": "greaterThan", | ||
| "aggregation": "added_count_times_ten", | ||
| "value": 9000 | ||
| }, | ||
| "intervals": [ | ||
| "2013-08-31T00:00/2013-09-01T00:00" | ||
| ] | ||
| }, | ||
| "expectedResults": [ | ||
| { | ||
| "version": "v1", | ||
| "timestamp": "2013-08-31T00:00:00.000Z", | ||
| "event": { | ||
| "added_count_times_ten": 9050.0, | ||
| "page": "Crimson Typhoon", | ||
| "added_count": 905, | ||
| "rows": 1 | ||
| } | ||
| }, | ||
| { | ||
| "version": "v1", | ||
| "timestamp": "2013-08-31T00:00:00.000Z", | ||
| "event": { | ||
| "added_count_times_ten": 9770.0, | ||
| "page": "Gypsy Danger", | ||
| "added_count": 977, | ||
| "rows": 1 | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] |
95 changes: 95 additions & 0 deletions
95
integration-tests/src/test/resources/indexer/wikipedia_combining_firehose_index_task.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| { | ||
| "type": "index", | ||
| "spec": { | ||
| "dataSchema": { | ||
| "dataSource": "%%DATASOURCE%%", | ||
| "metricsSpec": [ | ||
| { | ||
| "type": "count", | ||
| "name": "count" | ||
| }, | ||
| { | ||
| "type": "doubleSum", | ||
| "name": "added", | ||
| "fieldName": "added" | ||
| }, | ||
| { | ||
| "type": "doubleSum", | ||
| "name": "deleted", | ||
| "fieldName": "deleted" | ||
| }, | ||
| { | ||
| "type": "doubleSum", | ||
| "name": "delta", | ||
| "fieldName": "delta" | ||
| }, | ||
| { | ||
| "name": "thetaSketch", | ||
| "type": "thetaSketch", | ||
| "fieldName": "user" | ||
| }, | ||
| { | ||
| "name": "quantilesDoublesSketch", | ||
| "type": "quantilesDoublesSketch", | ||
| "fieldName": "delta" | ||
| }, | ||
| { | ||
| "name": "HLLSketchBuild", | ||
| "type": "HLLSketchBuild", | ||
| "fieldName": "user" | ||
| } | ||
| ], | ||
| "granularitySpec": { | ||
| "segmentGranularity": "DAY", | ||
| "queryGranularity": "second", | ||
| "intervals" : [ "2013-08-31/2013-09-02" ] | ||
| }, | ||
| "parser": { | ||
| "parseSpec": { | ||
| "format" : "json", | ||
| "timestampSpec": { | ||
| "column": "timestamp" | ||
| }, | ||
| "dimensionsSpec": { | ||
| "dimensions": [ | ||
| "page", | ||
| {"type": "string", "name": "language", "createBitmapIndex": false}, | ||
| "user", | ||
| "unpatrolled", | ||
| "newPage", | ||
| "robot", | ||
| "anonymous", | ||
| "namespace", | ||
| "continent", | ||
| "country", | ||
| "region", | ||
| "city" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "ioConfig": { | ||
| "type": "index", | ||
| "firehose": { | ||
| "type": "combining", | ||
| "delegates": [ | ||
| { | ||
| "type": "local", | ||
| "baseDir": "/resources/indexer", | ||
| "filter": "wikipedia_combining_index_data.json" | ||
| }, | ||
| { | ||
| "type": "ingestSegment", | ||
| "dataSource": "%%COMBINING_DATASOURCE%%", | ||
| "interval": "2013-08-31/2013-09-02" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "tuningConfig": { | ||
| "type": "index", | ||
| "maxRowsPerSegment": 3 | ||
| } | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletions
3
integration-tests/src/test/resources/indexer/wikipedia_combining_index_data.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| {"timestamp": "2013-08-31T05:18:22Z", "page": "Gypsy Danger", "language" : "zh", "user" : "nuclear", "unpatrolled" : "true", "newPage" : "true", "robot": "false", "anonymous": "false", "namespace":"article", "continent":"North America", "country":"United States", "region":"Bay Area", "city":"San Francisco", "added": 977, "deleted": 200, "delta": -143} | ||
| {"timestamp": "2013-08-31T17:57:01Z", "page": "Striker Eureka", "language" : "en", "user" : "speed", "unpatrolled" : "false", "newPage" : "true", "robot": "true", "anonymous": "false", "namespace":"wikipedia", "continent":"Australia", "country":"Australia", "region":"Cantebury", "city":"Syndey", "added": 459, "deleted": 129, "delta": 330} | ||
| {"timestamp": "2013-09-01T18:22:39Z", "page": "Cherno Alpha", "language" : "ru", "user" : "masterYo", "unpatrolled" : "false", "newPage" : "true", "robot": "true", "anonymous": "false", "namespace":"article", "continent":"Asia", "country":"Russia", "region":"Oblast", "city":"Moscow", "added": 123, "deleted": 12, "delta": 111} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked for implementations of
FirehoseFactorythat do not also implementFiniteFirehoseFactoryand I found a few... eg.ClippedFirehoseFactory,FixedCountFirehoseFactory, etc.I think the underlying problem is in
IndexIOConfig#getNonNullInputSourceIndexIOConfigaccepts a FirehoseFactory, but getNonNullInputSource expects aFiniteFirehoseFactory.I wonder if we could fix this by creating an adapter that translates any FirehoseFactory into a non-splittable FiniteFirehoseFactory (ie. the same functionality you've implemented in this class).
I understand that the FirehoseFactories are deprecated, so I'm open to other ways of fixing the broken quickstart material as well - can we update the spec used so that the combining firehose factory works without a code change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that adding a non-splittable adapter would apply only to
CombiningFirehoseFactory.ClippedFirehoseFactory,TimedShutoffFirehoseFactoryandFixedCountFirehoseFactorycan be potentially splittable if the delegateFirehoseFactoryis splittable, it's just that they haven't been fixed yet.What we actually need is for index_parallel to support nested InputSource say DelegateInputSource. The delegate FirehoseFactories such as the ones listed above can then be easily provided their equivalent InputSource implementations. I've been looking at adding this support and hopefully can have a proposal out once I have something.