This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 0d51be61f65 [fix](Nereids) should distribute first when do sort enforce on must shuffle (#30948) (#30954) 0d51be61f65 is described below commit 0d51be61f656047ca76c9b47d8bf7c5f581abea5 Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Wed Feb 7 18:09:18 2024 +0800 [fix](Nereids) should distribute first when do sort enforce on must shuffle (#30948) (#30954) pick from master #30948 commit id d9c018e901 --- .../properties/EnforceMissingPropertiesHelper.java | 8 +++-- .../cte/test_cte_reuse_with_window.groovy | 39 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/EnforceMissingPropertiesHelper.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/EnforceMissingPropertiesHelper.java index d548e3254c4..700c32359a4 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/EnforceMissingPropertiesHelper.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/EnforceMissingPropertiesHelper.java @@ -130,9 +130,13 @@ public class EnforceMissingPropertiesHelper { private PhysicalProperties enforceSortAndDistribution(PhysicalProperties outputProperty, PhysicalProperties requiredProperty) { - PhysicalProperties enforcedProperty; + PhysicalProperties enforcedProperty = outputProperty; if (requiredProperty.getDistributionSpec().equals(new DistributionSpecGather())) { - enforcedProperty = enforceLocalSort(outputProperty, requiredProperty); + // NOTICE: if output is must shuffle, we must do distribution first. so add a random shuffle here. + if (outputProperty.getDistributionSpec() instanceof DistributionSpecMustShuffle) { + enforcedProperty = enforceDistribution(enforcedProperty, PhysicalProperties.EXECUTION_ANY); + } + enforcedProperty = enforceLocalSort(enforcedProperty, requiredProperty); enforcedProperty = enforceDistribution(enforcedProperty, requiredProperty); enforcedProperty = enforceGlobalSort(enforcedProperty, requiredProperty); } else { diff --git a/regression-test/suites/nereids_p0/cte/test_cte_reuse_with_window.groovy b/regression-test/suites/nereids_p0/cte/test_cte_reuse_with_window.groovy new file mode 100644 index 00000000000..431aeda7540 --- /dev/null +++ b/regression-test/suites/nereids_p0/cte/test_cte_reuse_with_window.groovy @@ -0,0 +1,39 @@ +// 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_cte_reuse_with_window") { + sql "SET enable_nereids_planner=true" + sql "SET enable_pipeline_engine=true" + sql "SET enable_fallback_to_original_planner=false" + + sql """ + drop table if exists test_cte_reuse_with_window; + """ + + sql """ + create table test_cte_reuse_with_window (id int default '10', c1 int default '10') distributed by hash(id) properties('replication_num'="1"); + """ + + sql """ + with temp as (select * from test_cte_reuse_with_window) + select * from + (select t.id, row_number() over(order by t.id) as num from temp t limit 20) a + left join + (select t.id, row_number() over(order by t.id desc) as num from temp t where t.id = 5) b + on a.id = b.id + """ +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org