-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: issue #8838 discard extra sort when sorted element is wrapped #9127
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
fcd15d7
0e52e55
a68ccb5
5850c5b
2bcb5c8
3f80656
9b912a7
c421604
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 |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # 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. | ||
|
|
||
| # prepare the table | ||
| statement ok | ||
| CREATE EXTERNAL TABLE delta_encoding_required_column ( | ||
| c_customer_sk INT NOT NULL, | ||
| c_current_cdemo_sk INT NOT NULL | ||
| ) | ||
| STORED AS CSV | ||
| WITH ORDER ( | ||
| c_customer_sk DESC, | ||
| c_current_cdemo_sk DESC | ||
| ) | ||
| LOCATION '../../testing/data/csv/aggregate_test_100.csv'; | ||
|
|
||
| # test for substitute CAST senario | ||
|
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. Can we also please add a test for times when casting may not preserve ordering? For exmaple if the input is If that is cast to Which is no longer sorted correctly 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. I can add that (maybe on the weekend) 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. added now |
||
| query TT | ||
| EXPLAIN | ||
| SELECT | ||
| CAST(c_customer_sk AS BIGINT) AS c_customer_sk_big, | ||
| c_current_cdemo_sk | ||
|
Comment on lines
+34
to
+36
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. If the select expressions were |
||
| FROM delta_encoding_required_column | ||
| ORDER BY c_customer_sk_big DESC, c_current_cdemo_sk DESC; | ||
| ---- | ||
| logical_plan | ||
| Sort: c_customer_sk_big DESC NULLS FIRST, delta_encoding_required_column.c_current_cdemo_sk DESC NULLS FIRST | ||
| --Projection: CAST(delta_encoding_required_column.c_customer_sk AS Int64) AS c_customer_sk_big, delta_encoding_required_column.c_current_cdemo_sk | ||
| ----TableScan: delta_encoding_required_column projection=[c_customer_sk, c_current_cdemo_sk] | ||
| physical_plan | ||
| SortPreservingMergeExec: [c_customer_sk_big@0 DESC,c_current_cdemo_sk@1 DESC] | ||
| --ProjectionExec: expr=[CAST(c_customer_sk@0 AS Int64) as c_customer_sk_big, c_current_cdemo_sk@1 as c_current_cdemo_sk] | ||
| ----RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 | ||
| ------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c_customer_sk, c_current_cdemo_sk], output_ordering=[c_customer_sk@0 DESC, c_current_cdemo_sk@1 DESC], has_header=false | ||
|
|
||
| # test for commom rename | ||
| query TT | ||
| EXPLAIN | ||
| SELECT | ||
| c_customer_sk AS c_customer_sk_big, | ||
| c_current_cdemo_sk | ||
| FROM delta_encoding_required_column | ||
| ORDER BY c_customer_sk_big DESC, c_current_cdemo_sk DESC; | ||
| ---- | ||
| logical_plan | ||
| Sort: c_customer_sk_big DESC NULLS FIRST, delta_encoding_required_column.c_current_cdemo_sk DESC NULLS FIRST | ||
| --Projection: delta_encoding_required_column.c_customer_sk AS c_customer_sk_big, delta_encoding_required_column.c_current_cdemo_sk | ||
| ----TableScan: delta_encoding_required_column projection=[c_customer_sk, c_current_cdemo_sk] | ||
| physical_plan | ||
| ProjectionExec: expr=[c_customer_sk@0 as c_customer_sk_big, c_current_cdemo_sk@1 as c_current_cdemo_sk] | ||
| --CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c_customer_sk, c_current_cdemo_sk], output_ordering=[c_customer_sk@0 DESC, c_current_cdemo_sk@1 DESC], has_header=false | ||
|
|
||
|
|
||
| # test for cast Utf8 | ||
| query TT | ||
| EXPLAIN | ||
| SELECT | ||
| CAST(c_customer_sk AS STRING) AS c_customer_sk_big, | ||
| c_current_cdemo_sk | ||
| FROM delta_encoding_required_column | ||
| ORDER BY c_customer_sk_big DESC, c_current_cdemo_sk DESC; | ||
| ---- | ||
| logical_plan | ||
| Sort: c_customer_sk_big DESC NULLS FIRST, delta_encoding_required_column.c_current_cdemo_sk DESC NULLS FIRST | ||
| --Projection: CAST(delta_encoding_required_column.c_customer_sk AS Utf8) AS c_customer_sk_big, delta_encoding_required_column.c_current_cdemo_sk | ||
| ----TableScan: delta_encoding_required_column projection=[c_customer_sk, c_current_cdemo_sk] | ||
| physical_plan | ||
| SortPreservingMergeExec: [c_customer_sk_big@0 DESC,c_current_cdemo_sk@1 DESC] | ||
| --SortExec: expr=[c_customer_sk_big@0 DESC,c_current_cdemo_sk@1 DESC] | ||
| ----ProjectionExec: expr=[CAST(c_customer_sk@0 AS Utf8) as c_customer_sk_big, c_current_cdemo_sk@1 as c_current_cdemo_sk] | ||
| ------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 | ||
| --------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c_customer_sk, c_current_cdemo_sk], output_ordering=[c_customer_sk@0 DESC, c_current_cdemo_sk@1 DESC], has_header=false | ||
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.
The schema of the file, and this table is not consistent. Additionally file doesn't satisfy the
WITH_ORDERinvariant given during creation.