This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new 5a7e46fe7b [fix](planner) fix non-equal out join is not supported (#9156) 5a7e46fe7b is described below commit 5a7e46fe7b87d5d14459247847ebcfc3052ef13b Author: shee <13843187+qz...@users.noreply.github.com> AuthorDate: Wed Apr 27 08:19:13 2022 -0700 [fix](planner) fix non-equal out join is not supported (#9156) --- .../java/org/apache/doris/analysis/TableRef.java | 11 ++++++- .../org/apache/doris/planner/QueryPlanTest.java | 34 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java index 4dd95a4b61..7536c370a0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java @@ -218,6 +218,7 @@ public class TableRef implements ParseNode, Writable { return null; } + public JoinOperator getJoinOp() { // if it's not explicitly set, we're doing an inner join return (joinOp == null ? JoinOperator.INNER_JOIN : joinOp); @@ -575,7 +576,15 @@ public class TableRef implements ParseNode, Writable { public void rewriteExprs(ExprRewriter rewriter, Analyzer analyzer) throws AnalysisException { Preconditions.checkState(isAnalyzed); - if (onClause != null) onClause = rewriter.rewrite(onClause, analyzer, ExprRewriter.ClauseType.ON_CLAUSE); + if (onClause != null) { + Expr expr = onClause.clone(); + onClause = rewriter.rewrite(onClause, analyzer, ExprRewriter.ClauseType.ON_CLAUSE); + if (joinOp.isOuterJoin() || joinOp.isSemiAntiJoin()) { + if (onClause instanceof BoolLiteral && !((BoolLiteral) onClause).getValue()) { + onClause = expr; + } + } + } } private String joinOpToSql() { diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java index 40d1541dda..ee09be1d8a 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java @@ -2120,4 +2120,38 @@ public class QueryPlanTest { String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, sql); Assert.assertTrue(explainString.contains("1 | 10 | 1 | 1 | 1")); } + + @Test + public void testOutJoinWithOnFalse() throws Exception { + connectContext.setDatabase("default_cluster:test"); + createTable("create table out_join_1\n" + + "(\n" + + " k1 int,\n" + + " v int\n" + + ")\n" + + "DISTRIBUTED BY HASH(k1) BUCKETS 10\n" + + "PROPERTIES(\"replication_num\" = \"1\");"); + + createTable("create table out_join_2\n" + + "(\n" + + " k1 int,\n" + + " v int\n" + + ")\n" + + "DISTRIBUTED BY HASH(k1) BUCKETS 10\n" + + "PROPERTIES(\"replication_num\" = \"1\");"); + + String sql = "explain select * from out_join_1 left join out_join_2 on out_join_1.k1 = out_join_2.k1 and 1=2;"; + String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, sql); + Assert.assertFalse(explainString.contains("non-equal LEFT OUTER JOIN is not supported")); + + sql = "explain select * from out_join_1 right join out_join_2 on out_join_1.k1 = out_join_2.k1 and 1=2;"; + explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, sql); + Assert.assertFalse(explainString.contains("non-equal RIGHT OUTER JOIN is not supported")); + + sql = "explain select * from out_join_1 full join out_join_2 on out_join_1.k1 = out_join_2.k1 and 1=2;"; + explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, sql); + Assert.assertFalse(explainString.contains("non-equal FULL OUTER JOIN is not supported")); + + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org