From 6a6c2d83735d5d2ec3d805d3e0a5b6e89c5544e0 Mon Sep 17 00:00:00 2001 From: 924060929 Date: Tue, 19 Nov 2024 15:20:27 +0800 Subject: [PATCH] fix --- .../ChildOutputPropertyDeriver.java | 24 +----- .../shuffle_storage_bucketed.groovy | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 regression-test/suites/nereids_syntax_p0/distribute/shuffle_storage_bucketed.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java index 1a95fb5f9e3807..11d35f933464ad 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java @@ -549,30 +549,10 @@ private ShuffleSide computeShuffleSide(DistributionSpecHash leftHashSpec, Distri ShuffleType rightShuffleType = rightHashSpec.getShuffleType(); switch (leftShuffleType) { case EXECUTION_BUCKETED: - if (rightShuffleType == ShuffleType.EXECUTION_BUCKETED) { - return ShuffleSide.BOTH; - } - break; case STORAGE_BUCKETED: - if (rightShuffleType == ShuffleType.NATURAL) { - // use storage hash to shuffle left to right to do bucket shuffle join - return ShuffleSide.LEFT; - } - break; + return rightShuffleType == ShuffleType.NATURAL ? ShuffleSide.LEFT : ShuffleSide.BOTH; case NATURAL: - switch (rightShuffleType) { - case NATURAL: - // colocate join - return ShuffleSide.NONE; - case STORAGE_BUCKETED: - // use storage hash to shuffle right to left to do bucket shuffle join - return ShuffleSide.RIGHT; - case EXECUTION_BUCKETED: - // compatible old ut - return ShuffleSide.RIGHT; - default: - } - break; + return rightShuffleType == ShuffleType.NATURAL ? ShuffleSide.NONE : ShuffleSide.RIGHT; default: } throw new IllegalStateException( diff --git a/regression-test/suites/nereids_syntax_p0/distribute/shuffle_storage_bucketed.groovy b/regression-test/suites/nereids_syntax_p0/distribute/shuffle_storage_bucketed.groovy new file mode 100644 index 00000000000000..884336d0b73f65 --- /dev/null +++ b/regression-test/suites/nereids_syntax_p0/distribute/shuffle_storage_bucketed.groovy @@ -0,0 +1,78 @@ +// 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("shuffle_storage_bucketed") { + multi_sql """ + drop table if exists du; + drop table if exists o; + drop table if exists ds; + + CREATE TABLE `du` ( + `et` datetime NOT NULL, + `st` datetime NOT NULL, + `gc` varchar(50) NOT NULL, + `pc` varchar(50) NOT NULL, + `uk` varchar(255) NOT NULL + ) ENGINE=OLAP + DUPLICATE KEY(`et`, `st`, `gc`, `pc`, `uk`) + DISTRIBUTED BY HASH(`gc`, `pc`) BUCKETS 4 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + + CREATE TABLE `o` ( + `d` date NULL, + `g` varchar(500) NULL, + `p` varchar(500) NULL, + `dt` datetime NULL + ) ENGINE=OLAP + DUPLICATE KEY(`d`, `g`, `p`) + DISTRIBUTED BY HASH(`g`, `p`) BUCKETS 4 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + + CREATE TABLE `ds` ( + `gc` varchar(50) NOT NULL, + `pc` varchar(50) NOT NULL, + `s` int NULL, + `n` varchar(50) NULL + ) ENGINE=OLAP + DUPLICATE KEY(`gc`, `pc`, `s`, `n`) + DISTRIBUTED BY HASH(`gc`, `pc`, `s`, `n`) BUCKETS 4 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + + set disable_nereids_rules='PRUNE_EMPTY_PARTITION'; + """ + + sql """ + explain plan + select * + from du + right outer join + ( + select g gc, p pc + from o + where date(dt) = '2020-05-25 00:00:00' + ) r + on r.gc=du.gc and r.pc=du.pc + left join ds s + on r.gc=s.gc and r.pc=s.pc; + """ +}