Hi All,

I am using the VolcanoPlanner(with Default Rules) to optimize a RelNode
which has a Join as below:-

LogicalJoin(condition=[AND(AND(AND(=($1, $46), =(CAST($11):FLOAT NOT NULL,
$47)), <>($46, -999)), <>($47, -999))], joinType=[left])
        LogicalTableScan(table=[[defaultschema, table1]])
        LogicalTableScan(table=[[defaultschema, table2]])

I removed the JoinPushThroughJoin.LEFT as the Planner never exits if BOTH
RIGHT & LEFT of this rule is in RuleSet. Reference to:-
https://issues.apache.org/jira/browse/CALCITE-1503

The setup code for planner:-

*RelOptPlanner planner = cluster.planner;*
*planner.removeRule(JoinPushThroughJoinRule.RIGHT);*
*RelNode convertedRel = planner.changeTraits(originalRel,
originalRel.traitSet.replace(EnumerableConvention.INSTANCE).simplify());*
*planner.setRoot(convertedRel);*
*planner.findBestExp();*

Now the RelNode that was returned has the following:-

EnumerableThetaJoin(condition=[AND(AND(AND(=($1, $47), =($43, $48)),* $95*),
*$96*)], joinType=[left])
      EnumerableProject(.....)
        EnumerableTableScan(table=[[defaultschema, table1]])
      EnumerableProject(......,$f51=[<>($3, -999)], $f52=[<>($4, -999)])
        EnumerableTableScan(table=[[defaultschema, table2]])

If we observe the underlined parts of  Join Condition of the
EnumerableThetaJoin, those are RexInputRef which was added to the Project
of Second TableScan.
Now when I use RelToSqlConverter to create a SqlString out of rel, it
expects all the conditions Operands to be an instance of
RexCall 
(calcite-core-1.14.0-sources.jar!/org/apache/calcite/rel/rel2sql/SqlImplementor.java:273)
but it gets a RexInputRef and throws an AssertionError.

Can somebody shed light on which Rule is responsible for doing so or am I
Initializing the planner incorrectly?

Reply via email to