Skip to content

Column alias in WHERE clause results in Binder Error #6055

@alexboks

Description

@alexboks

What happens?

A column alias of a column alias used in the where clause will cause a binder error

D with t0 (a) as (
>     select 1
> )
> select
>     a as b,
>     b as c
> from t0
> where c > 0;
Error: Binder Error: Referenced column "c" not found in FROM clause!
Candidate bindings: "t0.a"
LINE 8: where c > 0;
              ^

A column that is only aliased once seems to work though

D with t0 (a) as (
>     select 1
> )
> select
>     a as b,
>     b as c
> from t0
> where b > 0;
┌───────┬───────┐
│   b   │   c   │
│ int32 │ int32 │
├───────┼───────┤
│     1 │     1 │
└───────┴───────┘

To Reproduce

with t0 (a) as (
    select 1 
)
select 
    a as b,
    b as c
from t0
where c > 0

OS:

Windows

DuckDB Version:

0.6.1

DuckDB Client:

CLI

Full Name:

Alex Bokser

Affiliation:

Personal

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions