Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-881

Allow schema.table.column references in GROUP BY

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.5.0
    • None
    • None

    Description

      This works fine:

      SELECT DISTINCT "SA"."product"."brand_name" FROM "SA"."product";
      

      But this raises an NPE:

      Connecting to jdbc:calcite:model=inline:{"version":1.0,"defaultSchema":"SA","schemas":[{"name":"SA","type":"jdbc","jdbcSchema":"SA","jdbcUrl":"jdbc:derby:jar:(/opt/src/glimpse/glimpse/GlimpseServe/scala/target/scala-2.11/classes/derby-foodmart.zip)foodmart"}]}
      Connected to: Calcite (version 1.5.0-incubating-SNAPSHOT)
      Driver: Calcite JDBC Driver (version 1.5.0-incubating-SNAPSHOT)
      Autocommit status: true
      Transaction isolation: TRANSACTION_READ_UNCOMMITTED
      sqlline version 1.0.1 by Marc Prud'hommeaux
      0: jdbc:calcite:model=inline:{"version":1.0,"> SELECT "SA"."product"."brand_name" FROM "SA"."product" GROUP BY "SA"."product"."brand_name";
      Error: error while executing SQL "SELECT "SA"."product"."brand_name" FROM "SA"."product" GROUP BY "SA"."product"."brand_name"": null (state=,code=0)
      java.sql.SQLException: error while executing SQL "SELECT "SA"."product"."brand_name" FROM "SA"."product" GROUP BY "SA"."product"."brand_name"": null
      	at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:112)
      	at org.apache.calcite.avatica.AvaticaStatement.execute(AvaticaStatement.java:121)
      	at sqlline.SqlLine$Commands.execute(Unknown Source)
      	at sqlline.SqlLine$Commands.sql(Unknown Source)
      	at sqlline.SqlLine.dispatch(Unknown Source)
      	at sqlline.SqlLine.begin(Unknown Source)
      	at sqlline.SqlLine.mainWithInputRedirection(Unknown Source)
      	at sqlline.SqlLine.main(Unknown Source)
      Caused by: java.lang.NullPointerException
      	at org.apache.calcite.sql.validate.IdentifierNamespace.resolve(IdentifierNamespace.java:187)
      	at org.apache.calcite.sql.validate.IdentifierNamespace.getTable(IdentifierNamespace.java:195)
      	at org.apache.calcite.sql.validate.ListScope.findChild(ListScope.java:110)
      	at org.apache.calcite.sql.validate.ListScope.resolve(ListScope.java:164)
      	at org.apache.calcite.sql.validate.DelegatingScope.resolve(DelegatingScope.java:80)
      	at org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:176)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:4317)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:4297)
      	at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:271)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.expand(SqlValidatorImpl.java:4005)
      	at org.apache.calcite.sql.validate.SqlValidatorUtil.analyzeGroupExpr(SqlValidatorUtil.java:455)
      	at org.apache.calcite.sql.validate.SqlValidatorUtil.convertGroupSet(SqlValidatorUtil.java:426)
      	at org.apache.calcite.sql.validate.SqlValidatorUtil.analyzeGroupItem(SqlValidatorUtil.java:401)
      	at org.apache.calcite.sql.validate.AggregatingSelectScope.<init>(AggregatingSelectScope.java:94)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2166)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2088)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:802)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:518)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:564)
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:223)
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:189)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:700)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:586)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:556)
      	at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:207)
      	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:563)
      	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:477)
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:110)
      	... 7 more
      

      FTR, the same statement runs fine when executed directly against Derby.

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              mprudhom Marc Prud'hommeaux
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: