[ https://issues.apache.org/jira/browse/CALCITE-6007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17769811#comment-17769811 ]
Wenrui Meng commented on CALCITE-6007: -------------------------------------- [~julianhyde] thanks for help reviewing and merging the pr. > 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 > Assignee: Wenrui Meng > Priority: Major > Labels: pull-request-available > Fix For: 1.36.0 > > > {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)