This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit a59f9c3fa158ea24da288efba4022261c4826f9e Author: xueweizhang <zxw520bl...@163.com> AuthorDate: Fri May 17 18:07:31 2024 +0800 [fix](planner) fix unrequired slot bug when join node introduced by #25204 (#34923) before fix, join node will retain some slots, which are not materialized and unrequired. join node need remove these slots and not make them be output slots. Signed-off-by: nextdreamblue <zxw520bl...@163.com> --- .../org/apache/doris/planner/JoinNodeBase.java | 6 ++ .../test_inlineview_with_project.out | 9 ++- .../test_inlineview_with_project.groovy | 84 ++++++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java b/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java index fbe12b3d6a0..91a3c26e770 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java @@ -171,6 +171,9 @@ public abstract class JoinNodeBase extends PlanNode { boolean needSetToNullable = getChild(0) instanceof JoinNodeBase && analyzer.isOuterJoined(leftTupleDesc.getId()); for (SlotDescriptor leftSlotDesc : leftTupleDesc.getSlots()) { + if (!isMaterializedByChild(leftSlotDesc, getChild(0).getOutputSmap())) { + continue; + } SlotDescriptor outputSlotDesc = analyzer.getDescTbl().copySlotDescriptor(outputTupleDesc, leftSlotDesc); if (leftNullable) { @@ -191,6 +194,9 @@ public abstract class JoinNodeBase extends PlanNode { boolean needSetToNullable = getChild(1) instanceof JoinNodeBase && analyzer.isOuterJoined(rightTupleDesc.getId()); for (SlotDescriptor rightSlotDesc : rightTupleDesc.getSlots()) { + if (!isMaterializedByChild(rightSlotDesc, getChild(1).getOutputSmap())) { + continue; + } SlotDescriptor outputSlotDesc = analyzer.getDescTbl().copySlotDescriptor(outputTupleDesc, rightSlotDesc); if (rightNullable) { diff --git a/regression-test/data/correctness_p0/test_inlineview_with_project.out b/regression-test/data/correctness_p0/test_inlineview_with_project.out index e6ed3ee5706..1f85a6dff31 100644 --- a/regression-test/data/correctness_p0/test_inlineview_with_project.out +++ b/regression-test/data/correctness_p0/test_inlineview_with_project.out @@ -14,9 +14,9 @@ 3 -- !select5 -- -1 -2 -3 +1.0 +2.0 +3.0 -- !select5 -- 1 @@ -29,3 +29,6 @@ -- !select5 -- 3 +-- !select6 -- +2020-01-01 + diff --git a/regression-test/suites/correctness_p0/test_inlineview_with_project.groovy b/regression-test/suites/correctness_p0/test_inlineview_with_project.groovy index f13c45a5328..e769aa8c8ea 100644 --- a/regression-test/suites/correctness_p0/test_inlineview_with_project.groovy +++ b/regression-test/suites/correctness_p0/test_inlineview_with_project.groovy @@ -665,4 +665,88 @@ suite("test_inlineview_with_project") { sql """DROP TABLE IF EXISTS `dr_user_test_t1`;""" sql """DROP TABLE IF EXISTS `dr_user_test_t2`;""" + + sql """ + drop table if exists dws_mf_wms_join_t1; + """ + + sql """ + drop table if exists dws_mf_wms_join_t2; + """ + + + sql """CREATE TABLE `dws_mf_wms_join_t1` ( + `ddate` DATE NULL COMMENT '日期字段', + `game_id` VARCHAR(65533) NULL, + `main_currency_stock` BIGINT NULL + ) ENGINE=OLAP + DUPLICATE KEY(`ddate`) + DISTRIBUTED BY HASH(`ddate`) BUCKETS 10 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + );""" + + sql """CREATE TABLE `dws_mf_wms_join_t2` ( + `game_id` VARCHAR(65533) NULL, + ) ENGINE=OLAP + DUPLICATE KEY(`game_id`) + DISTRIBUTED BY HASH(`game_id`) BUCKETS 10 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + );""" + + sql """insert into dws_mf_wms_join_t1 values('2020-01-01','12345',100);""" + sql """insert into dws_mf_wms_join_t2 values('12345');""" + + qt_select6 """SELECT + a1.ddate + FROM + ( + SELECT + aaa.ddate + FROM + ( + SELECT + aa.ddate, + CONCAT('main', aa.main_currency_stock) AS arr, + ROW_NUMBER() OVER ( + PARTITION BY aa.ddate + ) AS rn + FROM + ( + SELECT + ddate, + main_currency_stock, + game_id + FROM + dws_mf_wms_join_t1 a + ) aa + LEFT JOIN ( + SELECT + game_id + FROM + dws_mf_wms_join_t2 + ) b ON aa.game_id = b.game_id + ) aaa + CROSS JOIN ( + select + 1 as newarr + ) b + WHERE + rn = 1 + ) a1 + GROUP BY + GROUPING SETS ( + ( + a1.ddate + ) + );""" + + sql """ + drop table if exists dws_mf_wms_join_join_t1; + """ + + sql """ + drop table if exists dws_mf_wms_join_join_t2; + """ } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org