xiedeyantu commented on code in PR #4490:
URL: https://github.com/apache/calcite/pull/4490#discussion_r2251030133
##########
core/src/main/java/org/apache/calcite/rel/rules/JoinCommuteRule.java:
##########
@@ -273,5 +280,18 @@ default Config withOperandFor(Class<? extends Join>
joinClass) {
/** Sets {@link #isAllowAlwaysTrueCondition()}. */
Config withAllowAlwaysTrueCondition(boolean allowAlwaysTrueCondition);
+
+ /**
+ * If true, only RIGHT joins will be swapped.
+ * Default is false.
+ */
+ @Value.Default default boolean isRightToLeftOnly() {
+ return false;
+ }
+
+ /**
+ * Sets {@link #isRightToLeftOnly()}.
+ */
+ Config withRightToLeftOnly(boolean rightToLeftOnly);
Review Comment:
```suggestion
Config withRightToLeftOnly(boolean isRightToLeftOnly);
```
##########
core/src/main/java/org/apache/calcite/rel/rules/JoinCommuteRule.java:
##########
@@ -273,5 +280,18 @@ default Config withOperandFor(Class<? extends Join>
joinClass) {
/** Sets {@link #isAllowAlwaysTrueCondition()}. */
Config withAllowAlwaysTrueCondition(boolean allowAlwaysTrueCondition);
+
+ /**
+ * If true, only RIGHT joins will be swapped.
Review Comment:
```suggestion
* If true, only RIGHT JOIN will be swapped.
```
##########
core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml:
##########
@@ -20515,6 +20515,52 @@ LogicalAggregate(group=[{0, 1}])
<Resource name="planAfter">
<![CDATA[
LogicalValues(tuples=[[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }]])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testSwapRightToLeftOnly">
+ <Resource name="sql">
+ <![CDATA[select 1 from sales.dept d right outer join sales.emp e
+ on d.deptno = e.deptno]]>
+ </Resource>
+ <Resource name="planBefore">
+ <![CDATA[
+LogicalProject(EXPR$0=[1])
+ LogicalJoin(condition=[=($0, $9)], joinType=[right])
+ LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+ </Resource>
+ <Resource name="planAfter">
+ <![CDATA[
+LogicalProject(EXPR$0=[1])
+ LogicalProject(DEPTNO=[$9], NAME=[$10], EMPNO=[$0], ENAME=[$1], JOB=[$2],
MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO0=[$7], SLACKER=[$8])
+ LogicalJoin(condition=[=($9, $7)], joinType=[left])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testSwapRightToLeftOnlyInner">
Review Comment:
`testSwapRightToLeftOnlyInner` is redundant and the entire xml should be
deleted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]