calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Pilloud (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CALCITE-2177) TUMBLE_START does not respect AS when SELECT and GROUP BY match
Date Wed, 14 Feb 2018 18:44:00 GMT
Andrew Pilloud created CALCITE-2177:
---------------------------------------

             Summary: TUMBLE_START does not respect AS when SELECT and GROUP BY match
                 Key: CALCITE-2177
                 URL: https://issues.apache.org/jira/browse/CALCITE-2177
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.13.0
            Reporter: Andrew Pilloud
            Assignee: Julian Hyde


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'"
{code:sql}
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
{code}
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'"
{code:sql}
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
{code}
 However swap the order of the select arguments and it works as expected:
{code:sql}
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
{code}
 

More detailed stack from second query:
{code:java}
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)
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message