Skip to content

WITH clauses' column aliases are not maintained correctly when selecting from CTE from within a derived table #822

@lukaseder

Description

@lukaseder

The following valid SQL statement fails

with 
  t1(f1, f2) as (
    select 1, 2
  )
select 
  a1.f1, 
  a1.f2
from (
  select * from t1
) a1

With the following error message:

Column "T1.F1" not found; SQL statement:
CREATE FORCE VIEW PUBLIC._16 AS
SELECT
    T1.F1,
    T1.F2
FROM (
    SELECT
        1,
        2
    FROM SYSTEM_RANGE(1, 1)
) [42122-196]

This works:

with 
  t1(f1, f2) as (
    select 1, 2
  )
select 
  a1.f1, 
  a1.f2
from t1 a1

The problem really seems to be related to nesting the CTE in a derived table


Probably related: #821

Metadata

Metadata

Assignees

No one assigned

    Labels

    WITH clauseRelated to the WITH clause implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions