From 2ebbc8924fc371ba2fba126121c09cb95a2982b4 Mon Sep 17 00:00:00 2001 From: chaoyli Date: Fri, 21 Aug 2020 15:32:52 +0800 Subject: [PATCH] [BUG] Remove the deduplication of LEFT SEMI/ANTI JOIN with not equal predicate ``` SELECT * FROM (SELECT cs_order_number, cs_warehouse_sk FROM catalog_sales WHERE cs_order_number = 125005 AND cs_warehouse_sk = 4) cs1 LEFT SEMI JOIN (SELECT cs_order_number, cs_warehouse_sk FROM catalog_sales WHERE cs_order_number = 125005) cs2 ON cs1.cs_order_number = cs2.cs_order_number AND cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk; ``` The above query has an equal predicate and a not equal predicate. If there exists not equal preidcate, the build table should be remained as it is. So the deduplication should be removed. --- be/src/exec/hash_join_node.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/be/src/exec/hash_join_node.cpp b/be/src/exec/hash_join_node.cpp index dea793ecfdb067..c120330daf7acf 100644 --- a/be/src/exec/hash_join_node.cpp +++ b/be/src/exec/hash_join_node.cpp @@ -75,6 +75,12 @@ Status HashJoinNode::init(const TPlanNode& tnode, RuntimeState* state) { Expr::create_expr_trees(_pool, tnode.hash_join_node.other_join_conjuncts, &_other_join_conjunct_ctxs)); + if (!_other_join_conjunct_ctxs.empty()) { + // If LEFT SEMI JOIN/LEFT ANTI JOIN with not equal predicate, + // build table should not be deduplicated. + _build_unique = false; + } + return Status::OK(); }