Skip to content

Column not found when CTE references another CTE #3508

@lukaseder

Description

@lukaseder

Given this valid query:

with 
  a(a) as (select 1),
  b(b) as (select a from a)
select * from b;

I'm getting an error:

"Column ""A"" not found [42122-212]"

The problem can be worked around by aliasing a in the CTE directly, so this works:

with 
  a(a) as (select 1 as a),
  b(b) as (select a from a)
select * from b;

Producing:

|B  |
|---|
|1  |

A side effect of the above bug (or it's an independent bug?) may be that this query also doesn't work:

with 
  a(a) as (select 1),
  b(b) as (select a from a)
select b from b;

The error is now:

Column "B" not found

Maybe, this error is just shadowing the original one?

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