Hi, devs.
I'm trying to implement RexVisitor#visitSubquery method for Flink Table API.
Can you help me with a problem?
1. I have to construct a RexNode while having a RexNode with left side of
IN (name of column) and RelNode, which stands for table or subquery on the
right side of IN operator. If I'm using RexSubQuery.in(rel, rex), I'm failing
with exception:
java.lang.ClassCastException: org.apache.calcite.rex.RexSubQuery cannot be cast
to org.apache.calcite.rex.RexLocalRef
at
org.apache.calcite.rex.RexProgramBuilder.registerInput(RexProgramBuilder.java:291)
at
org.apache.calcite.rex.RexProgramBuilder.addCondition(RexProgramBuilder.java:265)
at
org.apache.calcite.rel.rules.FilterToCalcRule.onMatch(FilterToCalcRule.java:66)
at
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:213)
at
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:819)
at
org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334)
at
org.apache.flink.api.table.BatchTableEnvironment.optimize(BatchTableEnvironment.scala:252)
at
org.apache.flink.api.table.BatchTableEnvironment.translate(BatchTableEnvironment.scala:287)
at
org.apache.flink.api.scala.table.BatchTableEnvironment.toDataSet(BatchTableEnvironment.scala:139)
at
org.apache.flink.api.scala.table.TableConversions.toDataSet(TableConversions.scala:41)
at
org.apache.flink.api.scala.batch.table.InITCase.testInSubquery(InITCase.scala:72)
RelBuilder#call doesn't take RelNode as parameter. Combining RelBuilder#call
with output of RexSubQuery.in(rel, rex) as RexNode causes duplicated IN
operator in logical plan:
LogicalFilter(condition=[IN(IN($2, {
LogicalProject(c=[$2])
LogicalFilter(condition=[=($1, 6)])
LogicalTableScan(table=[[_DataSetTable_0]])
}))])
LogicalTableScan(table=[[_DataSetTable_0]])
Besides, these classes look very similar.
So, the question is how to construct proper IN RexNode or how to cast from
RexSubQuery to RexNode.
Thanks in advance,
Nikolay Vasilishin
Junior Software Engineer
Office: +7 812 611 10 94<tel:+7%20812%20611%2010%2094> x 61997<tel:61997>
Cell: +7 921 403 78 55<tel:+7%20921%20403%2078%2055> Email:
[email protected]<mailto:[email protected]>
Saint-Petersburg, Russia (GMT+3) epam.com<http://www.epam.com>
CONFIDENTIALITY CAUTION AND DISCLAIMER
This message is intended only for the use of the individual(s) or entity(ies)
to which it is addressed and contains information that is legally privileged
and confidential. If you are not the intended recipient, or the person
responsible for delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited. All unintended recipients are obliged to
delete this message and destroy any printed copies.