[ https://issues.apache.org/jira/browse/CALCITE-6007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767725#comment-17767725 ]
Wenrui Meng commented on CALCITE-6007: -------------------------------------- The example you gave above will generate the following SQL statement when it's unparsed. {code:java} select EXPR$0.a, EXPR$0.b from ( select 1 as a, 2 as b) AS EXPR$0 where EXPR$0.a is not null {code} > CTE as subquery without alias doesn't have correct alias setup > -------------------------------------------------------------- > > Key: CALCITE-6007 > URL: https://issues.apache.org/jira/browse/CALCITE-6007 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.34.0, 1.35.0 > Reporter: Wenrui Meng > Priority: Major > > {code:java} > SELECT > a, > b > FROM ( > WITH > sub AS ( > SELECT > 1 AS a, > 2 AS b) > SELECT > * > FROM > sub) > WHERE > a IS NOT null > {code} > It will generate the following SQL statement after validation > {code:java} > SELECT > EXPR$0.a, > EXPR$0.b > FROM ( > WITH > sub AS ( > SELECT > 1 AS a, > 2 AS b) > SELECT > sub.a AS a, sub.b AS b > FROM > sub) > WHERE > EXPR$0.a IS NOT null > {code} > The validated SQL become invalid since there is no EXPR$0 alias append for > the SqlWith sub query but used in the expression outside. -- This message was sent by Atlassian Jira (v8.20.10#820010)