agavra commented on PR #9895:
URL: https://github.com/apache/pinot/pull/9895#issuecomment-1335927107

   @61yao instead of an optimization rule it should be implemented as a 
rewriter. I tested this and it works:
   
   ```java
   public class RightJoinRewriter extends SqlShuttle {
   
     public SqlNode visit(SqlCall call) {
       if (call instanceof SqlJoin) {
         SqlJoin join = (SqlJoin) call;
         if (join.getJoinType() == JoinType.RIGHT) {
           return super.visit(new SqlJoin(
               call.getParserPosition(),
               join.getRight(),
               join.isNaturalNode(),
               SqlLiteral.createSymbol(JoinType.LEFT, 
join.getJoinTypeNode().getParserPosition()),
               join.getLeft(),
               join.getConditionTypeNode(),
               join.getCondition()));
         }
       }
       return super.visit(call);
     }
   }
   ```
   
   And then I modified `CalciteSqlParser#extractSqlNodeAndOptions` to apply 
this rewriter:
   ```java
       return new SqlNodeAndOptions(statementNode.accept(new 
RightJoinRewriter()), sqlType, options);
   ```


-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to