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

AssertionError when GROUP BY nested field

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.19.0
    • Fix Version/s: 1.20.0
    • Component/s: core

      Description

      Calcite will throw AssertionError when GROUP BY nested field

      @Test
      public void test() {
      final String sql = "select coord.x, avg(coord.y) from customer.contact_peek GROUP BY coord.x";
      sql(sql).ok();
      }

       

      The stacktrace is 

      java.lang.AssertionError
      at org.apache.calcite.sql.validate.SqlValidatorUtil.analyzeGroupExpr(SqlValidatorUtil.java:839)
      at org.apache.calcite.sql.validate.SqlValidatorUtil.convertGroupSet(SqlValidatorUtil.java:791)
      at org.apache.calcite.sql.validate.SqlValidatorUtil.analyzeGroupItem(SqlValidatorUtil.java:748)
      at org.apache.calcite.sql.validate.AggregatingSelectScope.resolve(AggregatingSelectScope.java:104)
      at org.apache.calcite.sql.validate.AggregatingSelectScope.lambda$new$0(AggregatingSelectScope.java:65)
      at com.google.common.base.Suppliers$MemoizingSupplier.get(Suppliers.java:131)
      at org.apache.calcite.sql.validate.AggregatingSelectScope.nullifyType(AggregatingSelectScope.java:178)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1680)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1664)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:467)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4112)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3375)
      at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
      at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:996)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:956)
      at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:931)
      at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:638)
      at org.apache.calcite.test.SqlToRelTestBase$TesterImpl.convertSqlToRel(SqlToRelTestBase.java:608)
      at org.apache.calcite.test.SqlToRelTestBase$TesterImpl.assertConvertsTo(SqlToRelTestBase.java:723)
      at org.apache.calcite.test.SqlToRelConverterTest$Sql.convertsTo(SqlToRelConverterTest.java:3301)
      at org.apache.calcite.test.SqlToRelConverterTest$Sql.ok(SqlToRelConverterTest.java:3293)
      at org.apache.calcite.test.SqlToRelConverterTest.test(SqlToRelConverterTest.java:2680)

      The root cause is obvious and fix is just to remove the assertion line. Question is given that GROUP BY item should be validated beforehand, can we just delete this assertion?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                my7ym Will Yu
                Reporter:
                my7ym Will Yu
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 20m
                  2h 20m