Sergey Nuyanzin created CALCITE-7312:
----------------------------------------

             Summary: 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


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)

Reply via email to