Chris Miller created FLINK-15112:
------------------------------------

             Summary: NPE when trying to join on two temporal tables in a 
single query
                 Key: FLINK-15112
                 URL: https://issues.apache.org/jira/browse/FLINK-15112
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 1.9.1
            Reporter: Chris Miller


Joining on two temporal tables causes Flink's query optimizer to throw a 
NullPointerException. Below is an example query that causes this as well as the 
exception being thrown. I've also attached some test code that replicates the 
problem.

{{SELECT [o.id|http://o.id/] AS orderId, o.productId, o.currency, o.quantity, 
f.rate, p.price}}
{{ FROM Orders AS o,}}
{{ LATERAL TABLE (FxRateLookup(o.rowtime)) AS f,}}
{{ LATERAL TABLE (PriceLookup(o.rowtime)) AS p}}
{{ WHERE o.currency = f.currency}}
{{ AND o.productId = p.productId}}
The exception thrown is:
{code:java}
Exception in thread "main" java.lang.NullPointerExceptionException in thread 
"main" java.lang.NullPointerException at 
org.apache.flink.table.calcite.FlinkRelBuilder$.of(FlinkRelBuilder.scala:129) 
at 
org.apache.flink.table.plan.rules.logical.LogicalCorrelateToTemporalTableJoinRule.onMatch(LogicalCorrelateToTemporalTableJoinRule.scala:91)
 at 
org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:319)
 at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:560) at 
org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:419) at 
org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:284) 
at 
org.apache.calcite.plan.hep.HepInstruction$RuleCollection.execute(HepInstruction.java:74)
 at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:215) 
at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:202) at 
org.apache.flink.table.plan.Optimizer.runHepPlanner(Optimizer.scala:228) at 
org.apache.flink.table.plan.Optimizer.runHepPlannerSimultaneously(Optimizer.scala:212)
 at 
org.apache.flink.table.plan.Optimizer.optimizeExpandPlan(Optimizer.scala:138) 
at 
org.apache.flink.table.plan.StreamOptimizer.optimize(StreamOptimizer.scala:61) 
at 
org.apache.flink.table.planner.StreamPlanner.translateToType(StreamPlanner.scala:410)
 at 
org.apache.flink.table.planner.StreamPlanner.translate(StreamPlanner.scala:187) 
at 
org.apache.flink.table.planner.StreamPlanner.$anonfun$translate$1(StreamPlanner.scala:127)
 at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:233) 
at scala.collection.Iterator.foreach(Iterator.scala:937) at 
scala.collection.Iterator.foreach$(Iterator.scala:937) at 
scala.collection.AbstractIterator.foreach(Iterator.scala:1425) at 
scala.collection.IterableLike.foreach(IterableLike.scala:70) at 
scala.collection.IterableLike.foreach$(IterableLike.scala:69) at 
scala.collection.AbstractIterable.foreach(Iterable.scala:54) at 
scala.collection.TraversableLike.map(TraversableLike.scala:233) at 
scala.collection.TraversableLike.map$(TraversableLike.scala:226) at 
scala.collection.AbstractTraversable.map(Traversable.scala:104) at 
org.apache.flink.table.planner.StreamPlanner.translate(StreamPlanner.scala:127) 
at 
org.apache.flink.table.api.java.internal.StreamTableEnvironmentImpl.toDataStream(StreamTableEnvironmentImpl.java:319)
 at 
org.apache.flink.table.api.java.internal.StreamTableEnvironmentImpl.toAppendStream(StreamTableEnvironmentImpl.java:227)
 at 
org.apache.flink.table.api.java.internal.StreamTableEnvironmentImpl.toAppendStream(StreamTableEnvironmentImpl.java:218)
 at test.FlinkTest.run(FlinkTest.java:93) at 
test.FlinkTest.main(FlinkTest.java:23)
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to