You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "yanjing.wang (Jira)" <ji...@apache.org> on 2022/03/17 07:41:00 UTC
[jira] [Commented] (CALCITE-5045) Alias within GroupingSets throws type mis-match exception
[ https://issues.apache.org/jira/browse/CALCITE-5045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17508022#comment-17508022 ]
yanjing.wang commented on CALCITE-5045:
---------------------------------------
This problem is caused by that alias X has been expanded to 'empno / 2' in SELECT LIST, but not its copy, so 'empno / 2' in SELECT LIST will reuse 'empno / 2' data type in GROUP BY CUBE, rather derived from AggregatingSelectScope.
I will submit a PR after CALCITE-4512 is merged into the master.
> Alias within GroupingSets throws type mis-match exception
> ---------------------------------------------------------
>
> Key: CALCITE-5045
> URL: https://issues.apache.org/jira/browse/CALCITE-5045
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.29.0
> Environment: jdk8
> Reporter: yanjing.wang
> Assignee: yanjing.wang
> Priority: Major
> Fix For: 1.31.0
>
>
> {noformat}
> @Test void testAliasWithinGroupingSets() {
> final String sql = "SELECT empno / 2 AS x\n"
> + "FROM emp\n"
> + "GROUP BY ROLLUP(x)";
> sql(sql)
> .withConformance(SqlConformanceEnum.LENIENT)
> .ok();
> }{noformat}
> the above test throws
> {noformat}
> Conversion to relational algebra failed to preserve datatypes:
> validated type:
> RecordType(INTEGER NOT NULL X) NOT NULL
> converted type:
> RecordType(INTEGER X) NOT NULL{noformat}
> The X has lost its NOT NULL constraints.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)