Description
When the order of SELECT and GROUP BY arguments match, the output of TUMBLE_START and HOP_START can not be named with AS. Found while trying to implement Nexmark benchmark queries in Apache Beam.
This query fails with "An exception occured while executing the Java class. null: InvocationTargetException: Type 'RecordType(TIMESTAMP(0) $f0)' has no field 'starttime'"
SELECT B.starttime FROM (SELECT TUMBLE_START(B1.dateTime, INTERVAL '1' SECOND) AS starttime FROM Bid B1 GROUP BY TUMBLE(B1.dateTime, INTERVAL '1' SECOND)) B
This more useful query also fails with "An exception occured while executing the Java class. null: InvocationTargetException: Type 'RecordType(BIGINT auction, BIGINT price, TIMESTAMP(0) $f2)' has no field 'starttime'"
SELECT B.starttime FROM (SELECT B1.auction, B1.price, TUMBLE_START(B1.dateTime, INTERVAL '1' SECOND) AS starttime FROM Bid B1 GROUP BY B1.auction, B1.price, TUMBLE(B1.dateTime, INTERVAL '1' SECOND)) B
However swap the order of the select arguments and it works as expected:
SELECT B.starttime FROM (SELECT B1.price, B1.auction, TUMBLE_START(B1.dateTime, INTERVAL '1' SECOND) AS starttime FROM Bid B1 GROUP BY B1.auction, B1.price, TUMBLE(B1.dateTime, INTERVAL '1' SECOND)) B
More detailed stack from second query:
Caused by: java.lang.AssertionError: Type 'RecordType(TIMESTAMP(0) $f0, BIGINT auction, BIGINT price)' has no field 'starttime' at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.rex.RexBuilder.makeFieldAccess(RexBuilder.java:175) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:3533) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter.access$1800(SqlToRelConverter.java:210) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4545) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:3904) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:344) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4438) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectList(SqlToRelConverter.java:3744) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:662) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:619) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3054) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:555) at org.apache.beam.sdks.java.extensions.sql.repackaged.org.apache.calcite.prepare.PlannerImpl.rel(PlannerImpl.java:232) at org.apache.beam.sdk.extensions.sql.impl.planner.BeamQueryPlanner.convertToRelNode(BeamQueryPlanner.java:164)
Attachments
Issue Links
- blocks
-
BEAM-3182 [Nexmark][SQL] Implement supported queries
- Resolved