[
https://issues.apache.org/jira/browse/CALCITE-7312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18042776#comment-18042776
]
Sergey Nuyanzin commented on CALCITE-7312:
------------------------------------------
Merged as
[e7472d454f81bf3d86ef25709fbadd0d4892acc4|https://github.com/apache/calcite/commit/e7472d454f81bf3d86ef25709fbadd0d4892acc4]
> Alias is not auto generated for LATERAL TABLE
> ----------------------------------------------
>
> Key: CALCITE-7312
> URL: https://issues.apache.org/jira/browse/CALCITE-7312
> Project: Calcite
> Issue Type: Bug
> Reporter: Sergey Nuyanzin
> Assignee: Sergey Nuyanzin
> Priority: Major
> Labels: pull-request-available
>
> CALCITE-7217 fixed losing {{LATERAL}} while validation, however it seems it
> missed the case if alias is not specified, for instance
> {code:sql}
> select * from emp, lateral table(ramp(emp.deptno)), dept
> {code}
> then validation will rewrite query to
> {code:sql}
> SELECT SELECT `EMP`.`EMPNO`, `EMP`.`ENAME`, `EMP`.`JOB`, `EMP`.`MGR`,
> `EMP`.`HIREDATE`, `EMP`.`SAL`, `EMP`.`COMM`, `EMP`.`DEPTNO`, `EMP`.`SLACKER`,
> `EXPR$0`.`I`, `DEPT`.`DEPTNO` AS `DEPTNO0`, `DEPT`.`NAME`
> FROM `CATALOG`.`SALES`.`EMP` AS `EMP`,
> LATERAL TABLE(RAMP(`EMP`.`DEPTNO`))
> `CATALOG`.`SALES`.`DEPT` AS `DEPT`
> {code}
> thus it uses generated alias in projection however it doesn't add it to
> {{LATERAL TABLE}} in {{FROM}}
> so it should be
> {code:sql}
> SELECT `EMP`.`EMPNO`, `EMP`.`ENAME`, `EMP`.`JOB`, `EMP`.`MGR`,
> `EMP`.`HIREDATE`, `EMP`.`SAL`, `EMP`.`COMM`, `EMP`.`DEPTNO`, `EMP`.`SLACKER`,
> `EXPR$0`.`I`, `DEPT`.`DEPTNO` AS `DEPTNO0`, `DEPT`.`NAME`
> FROM `CATALOG`.`SALES`.`EMP` AS `EMP`,
> LATERAL TABLE(RAMP(`EMP`.`DEPTNO`)) AS `EXPR$0`,
> `CATALOG`.`SALES`.`DEPT` AS `DEPT`
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)