Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Nov 19, 2024
1 parent def0bc2 commit 6a6c2d8
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
"""
}

0 comments on commit 6a6c2d8

Please sign in to comment.