[
https://issues.apache.org/jira/browse/CALCITE-3003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16818677#comment-16818677
]
Will Yu commented on CALCITE-3003:
----------------------------------
[~Chunwei Lei] Not sure where it is not clear. It's just this line of code:
[link|https://github.com/apache/calcite/blob/9bce62c6b6abd13d551d0eed1f1e14b024bbb2ae/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java#L839]
I think author has a purpose of explicitly checking this and the assumption
here table should not have nested field. That's why I think it's an
improvement, but not a bug.
Removal of this line could work but not sure whether it will have other
impacts. [~julianhyde] Since you are the author of these lines, what do you
think on it? If ok, I will make a PR to remove this line. Thanks!
> AssertionError when GROUP BY nested field
> -----------------------------------------
>
> Key: CALCITE-3003
> URL: https://issues.apache.org/jira/browse/CALCITE-3003
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.19.0
> Reporter: Will Yu
> Priority: Minor
>
> Calcite will throw AssertionError when GROUP BY nested field
> {code:java}
> @Test
> public void test() {
> final String sql = "select coord.x, avg(coord.y) from customer.contact_peek
> GROUP BY coord.x";
> sql(sql).ok();
> }{code}
>
> The stacktrace is
> {code:java}
> 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){code}
> 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?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)