This is an automated email from the ASF dual-hosted git repository. xiong pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push: new 9fadc8f35e [CALCITE-5139] Improve Join print plan to add the CorrelationId info 9fadc8f35e is described below commit 9fadc8f35e76aec54e797bf4d1e83ec0479a047d Author: NobiGo <nobigo...@gmail.com> AuthorDate: Sun May 8 11:28:07 2022 +0800 [CALCITE-5139] Improve Join print plan to add the CorrelationId info --- core/src/main/java/org/apache/calcite/rel/core/Join.java | 1 + core/src/test/java/org/apache/calcite/test/RelBuilderTest.java | 10 +++++----- .../test/resources/org/apache/calcite/test/TopDownOptTest.xml | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/apache/calcite/rel/core/Join.java b/core/src/main/java/org/apache/calcite/rel/core/Join.java index 17b1e8bd11..0e461cd783 100644 --- a/core/src/main/java/org/apache/calcite/rel/core/Join.java +++ b/core/src/main/java/org/apache/calcite/rel/core/Join.java @@ -215,6 +215,7 @@ public abstract class Join extends BiRel implements Hintable { return super.explainTerms(pw) .item("condition", condition) .item("joinType", joinType.lowerName) + .itemIf("variablesSet", variablesSet, !variablesSet.isEmpty()) .itemIf( "systemFields", getSystemFieldList(), diff --git a/core/src/test/java/org/apache/calcite/test/RelBuilderTest.java b/core/src/test/java/org/apache/calcite/test/RelBuilderTest.java index 6f13e8736c..88a7cbad42 100644 --- a/core/src/test/java/org/apache/calcite/test/RelBuilderTest.java +++ b/core/src/test/java/org/apache/calcite/test/RelBuilderTest.java @@ -2419,7 +2419,7 @@ public class RelBuilderTest { .build(); // Note that the join is emitted since the query is not actually a correlated. final String expected = "" - + "LogicalJoin(condition=[=($5, 1000)], joinType=[left])\n" + + "LogicalJoin(condition=[=($5, 1000)], joinType=[left], variablesSet=[[$cor0]])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n"; assertThat(root, hasTree(expected)); @@ -4204,7 +4204,7 @@ public class RelBuilderTest { @Test void testSimpleSemiCorrelateViaJoin() { RelNode root = buildSimpleCorrelateWithJoin(JoinRelType.SEMI); final String expected = "" - + "LogicalJoin(condition=[=($7, $8)], joinType=[semi])\n" + + "LogicalJoin(condition=[=($7, $8)], joinType=[semi], variablesSet=[[$cor0]])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n"; assertThat( @@ -4228,7 +4228,7 @@ public class RelBuilderTest { @Test void testSimpleAntiCorrelateViaJoin() { RelNode root = buildSimpleCorrelateWithJoin(JoinRelType.ANTI); final String expected = "" - + "LogicalJoin(condition=[=($7, $8)], joinType=[anti])\n" + + "LogicalJoin(condition=[=($7, $8)], joinType=[anti], variablesSet=[[$cor0]])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n"; assertThat( @@ -4251,7 +4251,7 @@ public class RelBuilderTest { @Test void testSimpleLeftCorrelateViaJoin() { RelNode root = buildSimpleCorrelateWithJoin(JoinRelType.LEFT); final String expected = "" - + "LogicalJoin(condition=[=($7, $8)], joinType=[left])\n" + + "LogicalJoin(condition=[=($7, $8)], joinType=[left], variablesSet=[[$cor0]])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n"; assertThat( @@ -4275,7 +4275,7 @@ public class RelBuilderTest { @Test void testSimpleInnerCorrelateViaJoin() { RelNode root = buildSimpleCorrelateWithJoin(JoinRelType.INNER); final String expected = "" - + "LogicalJoin(condition=[=($7, $8)], joinType=[inner])\n" + + "LogicalJoin(condition=[=($7, $8)], joinType=[inner], variablesSet=[[$cor0]])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n"; assertThat("Join with correlate id but never used should be simplified to a join.", diff --git a/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml b/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml index a2eba172fd..b84bee83ed 100644 --- a/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml +++ b/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml @@ -38,7 +38,7 @@ LogicalProject(CONTACTNO=[$0], FNAME=[$1], LNAME=[$2], EMAIL=[$3], X=[$4], Y=[$5 <Resource name="planAfter"> <![CDATA[ EnumerableProject(CONTACTNO=[$0], FNAME=[$1], LNAME=[$2], EMAIL=[$3], X=[$4], Y=[$5], unit=[$6], COORD_NE=[ROW($7, ROW($8, $9))], ACCTNO=[$10], TYPE=[$11], BALANCE=[$12]) - EnumerableBatchNestedLoopJoin(condition=[AND(>($0, $10), <($3, $11))], joinType=[left], batchSize=[100]) + EnumerableBatchNestedLoopJoin(condition=[AND(>($0, $10), <($3, $11))], joinType=[left], variablesSet=[[$cor0, $cor1, $cor2, $cor3, $cor4, $cor5, $cor6, $cor7, $cor8, $cor9, $cor10, $cor11, $cor12, $cor13, $cor14, $cor15, $cor16, $cor17, $cor18, $cor19, $cor20, $cor21, $cor22, $cor23, $cor24, $cor25, $cor26, $cor27, $cor28, $cor29, $cor30, $cor31, $cor32, $cor33, $cor34, $cor35, $cor36, $cor37, $cor38, $cor39, $cor40, $cor41, $cor42, $cor43, $cor44, $cor45, $cor46, $cor47, $cor48, $cor4 [...] EnumerableSort(sort0=[$0], sort1=[$3], dir0=[DESC], dir1=[DESC]) EnumerableProject(CONTACTNO=[$0], FNAME=[$1], LNAME=[$2], EMAIL=[$3], X=[$4.X], Y=[$4.Y], unit=[$4.unit], M=[$5.M], A=[$5.SUB.A], B=[$5.SUB.B]) EnumerableTableScan(table=[[CATALOG, CUSTOMER, CONTACT_PEEK]]) @@ -67,7 +67,7 @@ LogicalSort(sort0=[$0], sort1=[$1], dir0=[DESC], dir1=[DESC]) </Resource> <Resource name="planAfter"> <![CDATA[ -EnumerableBatchNestedLoopJoin(condition=[AND(>($0, $3), <($1, $4))], joinType=[inner], batchSize=[100]) +EnumerableBatchNestedLoopJoin(condition=[AND(>($0, $3), <($1, $4))], joinType=[inner], variablesSet=[[$cor0, $cor1, $cor2, $cor3, $cor4, $cor5, $cor6, $cor7, $cor8, $cor9, $cor10, $cor11, $cor12, $cor13, $cor14, $cor15, $cor16, $cor17, $cor18, $cor19, $cor20, $cor21, $cor22, $cor23, $cor24, $cor25, $cor26, $cor27, $cor28, $cor29, $cor30, $cor31, $cor32, $cor33, $cor34, $cor35, $cor36, $cor37, $cor38, $cor39, $cor40, $cor41, $cor42, $cor43, $cor44, $cor45, $cor46, $cor47, $cor48, $cor49, [...] EnumerableLimit(fetch=[10]) EnumerableSort(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[DESC], dir1=[DESC], dir2=[ASC]) EnumerableProject(ENAME=[$1], JOB=[$2], MGR=[$3])