[BugFix] Fix multiple appendpipe error while revisiting parent AST#5322
Conversation
PR Reviewer Guide 🔍(Review updated until commit 9124702)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 9124702 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 0c3a695
Suggestions up to commit e07ed44
Suggestions up to commit 48bbc4b
|
visitAppendPipe re-visits parent AST in new planner context, causing assertion failure. Use relBuilder stack directly instead of AST re-visitation to stay within the same planner context. Signed-off-by: Songkan Tang <songkant@amazon.com>
Signed-off-by: Songkan Tang <songkant@amazon.com>
Signed-off-by: Songkan Tang <songkant@amazon.com>
Chained appendpipe queries can produce literal-only projections during prepare-time field trimming. Calcite may simplify those projections into Values, which can trigger planner mismatch assertions during execution. Preserve the Project shape for this narrow case in OpenSearchRelFieldTrimmer and add YAML REST regression coverage for double and triple appendpipe. Signed-off-by: Songkan Tang <songkant@amazon.com>
48bbc4b to
e07ed44
Compare
|
Persistent review updated to latest commit e07ed44 |
| openSearchRelBuilder.push(newInput); | ||
| openSearchRelBuilder.project(newProjects, newRowType.getFieldNames(), false, correlationIds); | ||
| return result(openSearchRelBuilder.build(), mapping, project); |
There was a problem hiding this comment.
In trimFields(Project, ...), the old openSearchRelBuilder.project(...) call could trigger Calcite's internal simplifyValues() when trimming produced a literal-only projection over a fixed-row-count input. That rewrite could replace the Project with Values, which is the shape that led to the planner mismatch in chained appendpipe.
|
As discussed offline, it's root cause is inconsistent planner/cluster are being used in trim phase and optimize phase. In original calcite, one prepare statement will be used through the whole process. While in PPL, we create 2 different prepares for analyzing and executing(including trimming, optimizing and planning, only trimming uses the planner from this new created prepare while others reuse the planner in RelNode). The ideal solution should be reusing the same planner for trimming as well. |
Signed-off-by: Songkan Tang <songkant@amazon.com>
|
Persistent review updated to latest commit 0c3a695 |
Signed-off-by: Songkan Tang <songkant@amazon.com>
|
Persistent review updated to latest commit 9124702 |
|
@qianheng-aws As suggested, prepare-time trimming now reuses the incoming RelNode's cluster so it stays aligned with the analyzed plan. The change also preserves pre-registered hint strategies required by PPL custom aggregate hints. If we find other prepare-time state that also needs to stay aligned with the incoming RelNode, we can address those cases incrementally. |
|
LGTM |
|
@songkant-aws the multiple |
|
@LantaoJin I checked Calcite already has some optimization rules for multiple LogicalUnions. Sometimes it can merge multiple unions into one. |
Description
Chained appendpipe queries can produce literal-only projections during prepare-time field trimming. Calcite may simplify those projections into Values, which can trigger planner mismatch assertions during execution. Preserve the Project shape for this narrow case in OpenSearchRelFieldTrimmer.
Related Issues
Resolves #5173
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.