-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](repeat plan) fix repeat output slot order inconsistent with its input expression #60045
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
[fix](repeat plan) fix repeat output slot order inconsistent with its input expression #60045
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
TPC-H: Total hot run time: 31367 ms |
TPC-DS: Total hot run time: 173815 ms |
ClickBench: Total hot run time: 26.69 s |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
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.
Pull request overview
This pull request fixes a critical bug in the Repeat node's output slot ordering in the Nereids planner. The BE requires that the repeat node's output slots follow a specific order: input expressions + GroupingID + other grouping functions. The previous physical translator implementation did not guarantee this ordering, which caused bad cast exceptions in the backend when executing queries with GROUPING SETS.
Changes:
- Refactored the PhysicalPlanTranslator to ensure correct output slot ordering for Repeat nodes
- Added comprehensive regression tests covering the fixed scenarios
- Fixed the logic to explicitly add group by expressions first, followed by aggregate function slots, then GroupingID, and finally grouping function slots
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java | Refactored visitPhysicalRepeat method to ensure correct output slot ordering: group by expressions → aggregate function slots → grouping ID → grouping function slots |
| regression-test/suites/nereids_p0/repeat/test_repeat_output_slot.groovy | Added regression test with two SQL queries using GROUPING SETS to verify the fix |
| regression-test/data/nereids_p0/repeat/test_repeat_output_slot.out | Expected output for the regression tests, including query plans and results |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
Outdated
Show resolved
Hide resolved
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
Show resolved
Hide resolved
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
Outdated
Show resolved
Hide resolved
morrySnow
left a comment
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.
add a ut for translate repeat
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
Outdated
Show resolved
Hide resolved
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
Outdated
Show resolved
Hide resolved
|
run buildall |
|
run buildall |
TPC-H: Total hot run time: 31381 ms |
TPC-DS: Total hot run time: 173591 ms |
ClickBench: Total hot run time: 26.56 s |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
… input expression (#60045) maybe relate PR: #21168 BE requires that the repeat node's output slot order should be inconsistent with its input expressions. That is output slots = input expressions + GroupingID + other grouping functions. But physical translator not ensure this requirement. Then sometimes the repeat may have bad cast exception. for sql: SELECT 100000 FROM db2.table_9_50_undef_partitions2_keys3_properties4_distributed_by5 GROUP BY GROUPING SETS ( (col_datetime_6__undef_signed, col_varchar_50__undef_signed) , () , (col_varchar_50__undef_signed) , (col_datetime_6__undef_signed, col_varchar_50__undef_signed) ); the above sql will have wrong ouput slot order then BE will have exceptions: (1105, 'errCode = 2, detailMessage = (172.20.57.146) [E-7412]assert cast err:[E-7412] Bad cast from type:doris::vectorized::ColumnVector<(doris::PrimitiveType)26> to doris::vectorized::ColumnStr<unsigned int> 0#doris::Exception::Exception(int, std::basic_string_view<char, std::char_traits<char> > const&, bool) at /home/zcp/repo_center/doris_master/doris/be/src/common/exception.cpp:0\n\t1# ...
… input expression (apache#60045) maybe relate PR: apache#21168 BE requires that the repeat node's output slot order should be inconsistent with its input expressions. That is output slots = input expressions + GroupingID + other grouping functions. But physical translator not ensure this requirement. Then sometimes the repeat may have bad cast exception. for sql: SELECT 100000 FROM db2.table_9_50_undef_partitions2_keys3_properties4_distributed_by5 GROUP BY GROUPING SETS ( (col_datetime_6__undef_signed, col_varchar_50__undef_signed) , () , (col_varchar_50__undef_signed) , (col_datetime_6__undef_signed, col_varchar_50__undef_signed) ); the above sql will have wrong ouput slot order then BE will have exceptions: (1105, 'errCode = 2, detailMessage = (172.20.57.146) [E-7412]assert cast err:[E-7412] Bad cast from type:doris::vectorized::ColumnVector<(doris::PrimitiveType)26> to doris::vectorized::ColumnStr<unsigned int> 0#doris::Exception::Exception(int, std::basic_string_view<char, std::char_traits<char> > const&, bool) at /home/zcp/repo_center/doris_master/doris/be/src/common/exception.cpp:0\n\t1# ...
intro by #59116
BE requires that the repeat node's output slot order should be inconsistent with its input expressions.
That is output slots = input expressions + GroupingID + other grouping functions.
But physical translator not ensure this requirement. Then sometimes the repeat may have bad cast exception.
for sql:
the above sql will have wrong ouput slot order:
then BE will have exceptions:
relate PR: #59116 may cause repeat's group by expression order not match repeat's output expression
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)