-
Notifications
You must be signed in to change notification settings - Fork 26.1k
ESQL: Fix ExchangeSinkExec output type #142489
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 6 commits
de8e2a5
3942dd0
befbc1a
6ed1ae0
1d6a36a
613e313
3ce094a
edfe402
41137ef
5f5596b
ccc33df
4a9a4f1
f139867
aea8e5f
747f5a3
a5c9b37
27ac3a2
34bf0b5
0303691
c80a7a8
633e8c7
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 |
|---|---|---|
|
|
@@ -128,8 +128,7 @@ public static Optional<ReductionPlan> planReduceDriverTopN( | |
| } | ||
| var updatedFragment = new Project(Source.EMPTY, withAddedDocToRelation, expectedDataOutput); | ||
| FragmentExec updatedFragmentExec = fragmentExec.withFragment(updatedFragment); | ||
| // TODO This ignores the possible change in output, see #141654 | ||
| ExchangeSinkExec updatedDataPlan = originalPlan.replaceChild(updatedFragmentExec); | ||
| ExchangeSinkExec updatedDataPlan = originalPlan.replaceChildAndUpdateOutput(updatedFragmentExec); | ||
|
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. Main fix here. |
||
|
|
||
| // Replace the TopN child with the data driver as the source. | ||
| PhysicalPlan reductionPlan = toPhysical(fragmentExec.fragment(), context).transformDown(TopNExec.class, t -> { | ||
|
|
@@ -138,9 +137,8 @@ public static Optional<ReductionPlan> planReduceDriverTopN( | |
| boolean fragmentIsSorted = updatedFragment.child() instanceof TopN; | ||
| return fragmentIsSorted ? t.replaceChild(exchangeExec).withSortedInput() : t.replaceChild(exchangeExec); | ||
| }); | ||
| ExchangeSinkExec reductionPlanWithSize = originalPlan.replaceChild( | ||
| EstimatesRowSize.estimateRowSize(updatedFragmentExec.estimatedRowSize(), reductionPlan) | ||
| ); | ||
| PhysicalPlan sizedReductionPlan = EstimatesRowSize.estimateRowSize(updatedFragmentExec.estimatedRowSize(), reductionPlan); | ||
| ExchangeSinkExec reductionPlanWithSize = originalPlan.replaceChildAndUpdateOutput(sizedReductionPlan); | ||
|
|
||
| // The TopN reduction plan should not be further optimized locally on the node reduce driver, since we took great pains to | ||
| // preplan in advance, including all the necessary field extractions! | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] | ||
| ExchangeSinkExec[[_doc{f}, hire_date{f}],false] | ||
| \_ProjectExec[[_doc{f}, hire_date{f}]] | ||
| \_FieldExtractExec[hire_date{f}]<[],[]> | ||
| \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] | ||
| ExchangeSinkExec[[_doc{f}, hire_date{f}, height{f}],false] | ||
| \_ProjectExec[[_doc{f}, hire_date{f}, height{f}]] | ||
| \_FieldExtractExec[hire_date{f}, height{f}]<[],[]> | ||
| \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST], FieldSort[field=height{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[32] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] | ||
| ExchangeSinkExec[[_doc{f}, hire_date{f}],false] | ||
| \_ProjectExec[[_doc{f}, hire_date{f}]] | ||
| \_FieldExtractExec[hire_date{f}]<[],[]> | ||
| \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ExchangeSinkExec[[emp_no{f}, height{f}],false] | ||
| ExchangeSinkExec[[_doc{f}, height{f}],false] | ||
| \_ProjectExec[[_doc{f}, height{f}]] | ||
| \_FieldExtractExec[height{f}]<[],[]> | ||
| \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=height{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ExchangeSinkExec[[hire_date{f}, salary{f}],false] | ||
| ExchangeSinkExec[[_doc{f}, hire_date{f}],false] | ||
| \_ProjectExec[[_doc{f}, hire_date{f}]] | ||
| \_FieldExtractExec[hire_date{f}]<[],[]> | ||
| \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] | ||
| ExchangeSinkExec[[_doc{f}, hire_date{r}],false] | ||
|
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. thought: With and without my test fix, we have an interesting situation here: the exchange doesn't return a field attribute anymore, but a reference attribute (because we intentionally shadowed the This is correct, but means we cannot assume that attribute type remains consistent for an exchange after optimization. |
||
| \_ProjectExec[[_doc{f}, birth_date{r} AS hire_date]] | ||
| \_EvalExec[[null[DATETIME] AS birth_date]] | ||
|
alex-spies marked this conversation as resolved.
Outdated
|
||
| \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] | ||
Uh oh!
There was an error while loading. Please reload this page.