-
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
Merged
morrySnow
merged 3 commits into
apache:master
from
yujun777:fix-repeat-output-slot-order
Jan 23, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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
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
70 changes: 70 additions & 0 deletions
70
regression-test/data/nereids_p0/repeat/test_repeat_output_slot.out
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,70 @@ | ||
| -- This file is automatically generated. You should know what you did if you want to edit this | ||
| -- !sql_1_shape -- | ||
| PhysicalCteAnchor ( cteId=CTEId#0 ) | ||
| --PhysicalCteProducer ( cteId=CTEId#0 ) | ||
| ----hashAgg[GLOBAL] | ||
| ------PhysicalProject | ||
| --------PhysicalOlapScan[tbl_test_repeat_output_slot] | ||
| --PhysicalResultSink | ||
| ----PhysicalProject | ||
| ------PhysicalUnion | ||
| --------PhysicalProject | ||
| ----------hashAgg[GLOBAL] | ||
| ------------hashAgg[LOCAL] | ||
| --------------PhysicalRepeat | ||
| ----------------PhysicalCteConsumer ( cteId=CTEId#0 ) | ||
| --------PhysicalProject | ||
| ----------PhysicalCteConsumer ( cteId=CTEId#0 ) | ||
|
|
||
| -- !sql_1_result -- | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
| 100000 | ||
|
|
||
| -- !sql_2_shape -- | ||
| PhysicalCteAnchor ( cteId=CTEId#0 ) | ||
| --PhysicalCteProducer ( cteId=CTEId#0 ) | ||
| ----hashAgg[GLOBAL] | ||
| ------hashAgg[LOCAL] | ||
| --------PhysicalProject | ||
| ----------PhysicalOlapScan[tbl_test_repeat_output_slot] | ||
| --PhysicalResultSink | ||
| ----PhysicalProject | ||
| ------PhysicalUnion | ||
| --------PhysicalProject | ||
| ----------filter((GROUPING_PREFIX_col_varchar_50__undef_signed__index_inverted_col_datetime_6__undef_signed_col_varchar_50__undef_signed > 0)) | ||
| ------------hashAgg[GLOBAL] | ||
| --------------hashAgg[LOCAL] | ||
| ----------------PhysicalRepeat | ||
| ------------------PhysicalCteConsumer ( cteId=CTEId#0 ) | ||
| --------PhysicalEmptyRelation | ||
|
|
||
| -- !sql_2_result -- | ||
| \N ALL 1 6 \N \N \N | ||
| \N ALL 1 6 \N \N \N | ||
| 2020-01-02T00:00 ALL 1 6 \N 2020-01-02T00:00 \N | ||
| 2020-01-02T00:00 ALL 1 6 \N 2020-01-02T00:00 \N | ||
| 2020-01-03T00:00 ALL 1 6 \N 2020-01-03T00:00 \N | ||
| 2020-01-03T00:00 ALL 1 6 \N 2020-01-03T00:00 \N | ||
| 2020-01-04T00:00 ALL 1 6 \N 2020-01-04T00:00 \N | ||
| 2020-01-04T00:00 ALL 1 6 \N 2020-01-04T00:00 \N | ||
| 2020-01-04T00:00 ALL 1 7 \N \N \N | ||
|
|
82 changes: 82 additions & 0 deletions
82
regression-test/suites/nereids_p0/repeat/test_repeat_output_slot.groovy
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. | ||
|
|
||
| suite("test_repeat_output_slot") { | ||
| sql """ | ||
| SET enable_fallback_to_original_planner=false; | ||
| SET enable_nereids_planner=true; | ||
| SET ignore_shape_nodes='PhysicalDistribute'; | ||
| SET disable_nereids_rules='PRUNE_EMPTY_PARTITION'; | ||
| SET runtime_filter_mode=OFF; | ||
| SET disable_join_reorder=true; | ||
|
|
||
| DROP TABLE IF EXISTS tbl_test_repeat_output_slot FORCE; | ||
|
|
||
| """ | ||
|
|
||
| sql """ | ||
| CREATE TABLE tbl_test_repeat_output_slot ( | ||
| col_datetime_6__undef_signed datetime(6), | ||
| col_varchar_50__undef_signed varchar(50), | ||
| col_varchar_50__undef_signed__index_inverted varchar(50) | ||
| ) engine=olap | ||
| distributed by hash(col_datetime_6__undef_signed) buckets 10 | ||
| properties('replication_num' = '1'); | ||
| """ | ||
|
|
||
| sql """ | ||
| INSERT INTO tbl_test_repeat_output_slot VALUES | ||
| (null, null, null), (null, "a", "x"), (null, "a", "y"), | ||
| ('2020-01-02', "b", "x"), ('2020-01-02', 'a', 'x'), ('2020-01-02', 'b', 'y'), | ||
| ('2020-01-03', 'a', 'x'), ('2020-01-03', 'a', 'y'), ('2020-01-03', 'b', 'x'), ('2020-01-03', 'b', 'y'), | ||
| ('2020-01-04', 'a', 'x'), ('2020-01-04', 'a', 'y'), ('2020-01-04', 'b', 'x'), ('2020-01-04', 'b', 'y'); | ||
| """ | ||
|
|
||
| explainAndOrderResult 'sql_1', ''' | ||
| SELECT 100000 | ||
| FROM tbl_test_repeat_output_slot | ||
| 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) | ||
| ); | ||
| ''' | ||
|
|
||
| explainAndOrderResult 'sql_2', ''' | ||
| SELECT MAX(col_datetime_6__undef_signed) AS total_col_datetime, | ||
| CASE WHEN GROUPING(col_varchar_50__undef_signed__index_inverted) = 1 THEN 'ALL' | ||
| ELSE CAST(col_varchar_50__undef_signed__index_inverted AS VARCHAR) | ||
| END AS pretty_val, | ||
| IF(GROUPING_ID(col_varchar_50__undef_signed__index_inverted, | ||
| col_datetime_6__undef_signed, | ||
| col_varchar_50__undef_signed) > 0, 1, 0) AS is_agg_row, | ||
| GROUPING_ID(col_varchar_50__undef_signed__index_inverted, | ||
| col_datetime_6__undef_signed, col_varchar_50__undef_signed) AS having_filter_col, | ||
| col_varchar_50__undef_signed__index_inverted, | ||
| col_datetime_6__undef_signed, | ||
| col_varchar_50__undef_signed | ||
| FROM tbl_test_repeat_output_slot | ||
| GROUP BY GROUPING SETS ( | ||
| (col_varchar_50__undef_signed__index_inverted, col_datetime_6__undef_signed, col_varchar_50__undef_signed), | ||
| (), | ||
| (col_varchar_50__undef_signed), | ||
| (col_varchar_50__undef_signed__index_inverted, col_datetime_6__undef_signed, col_varchar_50__undef_signed), | ||
| (col_varchar_50__undef_signed)) | ||
| HAVING having_filter_col > 0; | ||
| ''' | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.