Skip to content

Commit

Permalink
[fix](nereids) Create Runtime filter even if equal.right is not in al…
Browse files Browse the repository at this point in the history
…iasTransferMap (apache#46406)

### What problem does this PR solve?
fix a bug introduced by apache#40815
  • Loading branch information
englefly authored Jan 6, 2025
1 parent b5fad03 commit a539e22
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ public PhysicalPlan visitPhysicalHashJoin(PhysicalHashJoin<? extends Plan, ? ext
continue;
}
long buildSideNdv = getBuildSideNdv(join, equalTo);
Pair<PhysicalRelation, Slot> pair = ctx.getAliasTransferMap().get(equalTo.right());
if (pair == null) {
continue;
}
if (equalTo.left().getInputSlots().size() == 1) {
RuntimeFilterPushDownVisitor.PushDownContext pushDownContext =
RuntimeFilterPushDownVisitor.PushDownContext.createPushDownContextForHashJoin(
Expand Down
16 changes: 16 additions & 0 deletions regression-test/data/nereids_p0/runtime_filter/check_rf.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !1 --
PhysicalResultSink
--PhysicalDistribute[DistributionSpecGather]
----PhysicalProject
------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.id = t2.maxId)) otherCondition=() build RFs:RF0 maxId->[id]
--------PhysicalProject
----------PhysicalOlapScan[t1] apply RFs: RF0
--------PhysicalProject
----------hashAgg[GLOBAL]
------------PhysicalDistribute[DistributionSpecHash]
--------------hashAgg[LOCAL]
----------------PhysicalProject
------------------filter((t1.id < 100))
--------------------PhysicalOlapScan[t1]

51 changes: 51 additions & 0 deletions regression-test/suites/nereids_p0/runtime_filter/check_rf.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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("check_rf") {
sql """
drop table if exists t1;
set disable_join_reorder=true;
set enable_parallel_result_sink=false;
set runtime_filter_type=2;
"""
sql """
CREATE TABLE IF NOT EXISTS t1 (
`app_name` VARCHAR(64) NULL COMMENT '标识',
`event_id` VARCHAR(128) NULL COMMENT '标识',
`decision` VARCHAR(32) NULL COMMENT '枚举值',
`time` DATETIME NULL COMMENT '查询时间',
`id` int NOT NULL COMMENT 'od'
)
DISTRIBUTED BY HASH(event_id)
BUCKETS 3 PROPERTIES ("replication_num" = "1");
"""

sql """
insert into t1 values
('aa', 'bc', 'cc', '2024-07-03 01:15:30', 1),
('ab', 'bc', 'cc', '2024-07-03 01:15:30', 2),
('ac', 'bc', 'cc', '2024-07-03 01:15:30', 3),
('ad', 'bc', 'cc', '2024-07-03 01:15:30', 4);
"""

// even if equalTo.right is not in aliasTransferMap, generate the rf
qt_1 """
explain shape plan
select t1.app_name
from t1 join (select max(id) as maxId from t1 where id < 100 group by app_name) t2 on t1.id = t2.maxId;
"""
}

0 comments on commit a539e22

Please sign in to comment.