-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Planning correctly for order by queries on time which previously thre… #13965
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
Changes from all commits
06b576b
5907d41
a6f73eb
a9fdcb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7306,21 +7306,26 @@ public void testMinMaxAvgDailyCountWithLimit() | |
| ) | ||
| ) | ||
| .setInterval(querySegmentSpec(Filtration.eternity())) | ||
| .setLimitSpec( | ||
| new DefaultLimitSpec( | ||
| ImmutableList.of(), | ||
| 1 | ||
| ) | ||
| ) | ||
| .setGranularity(Granularities.ALL) | ||
| .setAggregatorSpecs( | ||
| useDefault ? | ||
| aggregators( | ||
| new LongMaxAggregatorFactory("_a0", "a0"), | ||
| new LongMinAggregatorFactory("_a1", "a0"), | ||
| new LongSumAggregatorFactory("_a2:sum", "a0"), | ||
| new CountAggregatorFactory("_a2:count"), | ||
| new LongMaxAggregatorFactory("_a3", "d0"), | ||
| new CountAggregatorFactory("_a4") | ||
| ) : aggregators( | ||
| new LongMaxAggregatorFactory("_a0", "a0"), | ||
| new LongMinAggregatorFactory("_a1", "a0"), | ||
| new LongSumAggregatorFactory("_a2:sum", "a0"), | ||
| new FilteredAggregatorFactory( | ||
| new CountAggregatorFactory("_a2:count"), | ||
| not(selector("a0", null, null)) | ||
| ), | ||
| new LongMaxAggregatorFactory("_a3", "d0"), | ||
| new CountAggregatorFactory("_a4") | ||
|
Comment on lines
+7319
to
+7328
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this change generate this adjustment to the plan?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No clue but in the case of the useDefault=false it uses the same thing but with a check of not null so thought it was kind of correct |
||
| ) | ||
| ) | ||
| .setPostAggregatorSpecs( | ||
|
|
@@ -7333,7 +7338,7 @@ public void testMinMaxAvgDailyCountWithLimit() | |
| new FieldAccessPostAggregator(null, "_a2:count") | ||
| ) | ||
| ), | ||
| expressionPostAgg("s0", "timestamp_extract(\"_a3\",'EPOCH','UTC')") | ||
| expressionPostAgg("p0", "timestamp_extract(\"_a3\",'EPOCH','UTC')") | ||
| ) | ||
| ) | ||
| .setContext(QUERY_CONTEXT_DEFAULT) | ||
|
|
@@ -14604,4 +14609,88 @@ public void testComplexDecodeAgg() | |
| ) | ||
| ); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOrderByAlongWithInternalScanQuery() | ||
| { | ||
| testQuery( | ||
| "select __time as t, m1 from druid.foo where (m1 in (select distinct m1 from druid.foo)) order by 1 limit 1", | ||
| ImmutableList.of( | ||
| newScanQueryBuilder() | ||
| .intervals(querySegmentSpec(Filtration.eternity())) | ||
| .dataSource( | ||
| JoinDataSource.create( | ||
| new TableDataSource(CalciteTests.DATASOURCE1), | ||
| new QueryDataSource( | ||
| GroupByQuery.builder() | ||
| .setGranularity(Granularities.ALL) | ||
| .setDataSource(CalciteTests.DATASOURCE1) | ||
| .setInterval(querySegmentSpec(Intervals.of( | ||
| "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"))) | ||
| .setDimensions(new DefaultDimensionSpec("m1", "d0", ColumnType.FLOAT)) | ||
| .build() | ||
| ), | ||
| "j0.", | ||
| "(\"m1\" == \"j0.d0\")", | ||
| JoinType.INNER, | ||
| null, | ||
| ExprMacroTable.nil(), | ||
| CalciteTests.createJoinableFactoryWrapper() | ||
| ) | ||
| ) | ||
| .context(QUERY_CONTEXT_DEFAULT) | ||
| .intervals(querySegmentSpec(Intervals.of( | ||
| "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"))) | ||
| .limit(1) | ||
| .columns(ImmutableList.of("__time", "m1")) | ||
| .order(ScanQuery.Order.ASCENDING) | ||
| .build() | ||
| ), | ||
| ImmutableList.of( | ||
| new Object[]{946684800000L, 1.0f} | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOrderByAlongWithInternalScanQueryNoDistinct() | ||
| { | ||
| testQuery( | ||
| "select __time, m1 from druid.foo where (m1 in (select m1 from druid.foo)) order by __time DESC limit 1", | ||
| ImmutableList.of( | ||
| newScanQueryBuilder() | ||
| .intervals(querySegmentSpec(Filtration.eternity())) | ||
| .dataSource( | ||
| JoinDataSource.create( | ||
| new TableDataSource(CalciteTests.DATASOURCE1), | ||
| new QueryDataSource( | ||
| GroupByQuery.builder() | ||
| .setGranularity(Granularities.ALL) | ||
| .setDataSource(CalciteTests.DATASOURCE1) | ||
| .setInterval(querySegmentSpec(Intervals.of( | ||
| "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"))) | ||
| .setDimensions(new DefaultDimensionSpec("m1", "d0", ColumnType.FLOAT)) | ||
| .build() | ||
| ), | ||
| "j0.", | ||
| "(\"m1\" == \"j0.d0\")", | ||
| JoinType.INNER, | ||
| null, | ||
| ExprMacroTable.nil(), | ||
| CalciteTests.createJoinableFactoryWrapper() | ||
| ) | ||
| ) | ||
| .context(QUERY_CONTEXT_DEFAULT) | ||
| .intervals(querySegmentSpec(Intervals.of( | ||
| "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"))) | ||
| .limit(1) | ||
| .columns(ImmutableList.of("__time", "m1")) | ||
| .order(ScanQuery.Order.DESCENDING) | ||
| .build() | ||
| ), | ||
| ImmutableList.of( | ||
| new Object[]{978480000000L, 6.0f} | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
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.
This was a change in #12418 that was reverted. Since we are using a table data source and not a query data source now the isConcrete() check is not needed and can be removed