[fix](nereids) generate correct order for runtime filter when contains NullSafeEquals hash condition (#29726)

Be do not support RF for NullSafeEquals, so fe not generate RF for them.
However, after we support NullSafeEquals as Hash join condition,
the order of RF is wrong when generating RF in FE. this PR fix it.
This commit is contained in:
minghong
2024-01-10 10:23:44 +08:00
committed by yiguolei
parent e2ccca6290
commit 3675e0302c
2 changed files with 60 additions and 10 deletions

View File

@ -368,18 +368,20 @@ public class RuntimeFilterGenerator extends PlanPostProcessor {
.filter(type -> (type.getValue() & ctx.getSessionVariable().getRuntimeFilterType()) > 0)
.collect(Collectors.toList());
List<EqualTo> hashJoinConjuncts = join.getEqualToConjuncts();
List<Expression> hashJoinConjuncts = join.getHashJoinConjuncts().stream().collect(Collectors.toList());
for (int i = 0; i < hashJoinConjuncts.size(); i++) {
EqualTo equalTo = ((EqualTo) JoinUtils.swapEqualToForChildrenOrder(
hashJoinConjuncts.get(i), join.left().getOutputSet()));
for (TRuntimeFilterType type : legalTypes) {
//bitmap rf is generated by nested loop join.
if (type == TRuntimeFilterType.BITMAP) {
continue;
if (hashJoinConjuncts.get(i) instanceof EqualTo) {
EqualTo equalTo = ((EqualTo) JoinUtils.swapEqualToForChildrenOrder(
(EqualTo) hashJoinConjuncts.get(i), join.left().getOutputSet()));
for (TRuntimeFilterType type : legalTypes) {
//bitmap rf is generated by nested loop join.
if (type == TRuntimeFilterType.BITMAP) {
continue;
}
long buildSideNdv = getBuildSideNdv(join, equalTo);
join.pushDownRuntimeFilter(context, generator, join, equalTo.right(),
equalTo.left(), type, buildSideNdv, i);
}
long buildSideNdv = getBuildSideNdv(join, equalTo);
join.pushDownRuntimeFilter(context, generator, join, equalTo.right(),
equalTo.left(), type, buildSideNdv, i);
}
}
}

View File

@ -0,0 +1,48 @@
// 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("runtime_filter") {
sql ''' drop table if exists rf_dws_asset_domain_statistics_daily'''
sql '''CREATE TABLE rf_dws_asset_domain_statistics_daily (
account_id int(11) NULL,
ssp_id int(11) NULL,
account_name varchar(500) NULL,
d_s date NOT NULL
) ENGINE = OLAP
DUPLICATE KEY(account_id, ssp_id, account_name) COMMENT 'OLAP'
PARTITION BY RANGE(d_s) (PARTITION p20231220 VALUES [('2023-12-20'), ('2023-12-21')))
DISTRIBUTED BY HASH(account_name) BUCKETS 9
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
); '''
sql "set runtime_filter_mode=GLOBAL"
explain {
sql """
SELECT count(*) FROM
rf_dws_asset_domain_statistics_daily t1
INNER JOIN (
SELECT account_id, account_name
FROM dws_asset_domain_statistics_daily
WHERE d_s = '2023-12-20'
) t2
ON (t1.account_id <=> t2.account_id);
"""
notContains("RFs")
}
}