- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
Description
Describe the bug
A construction like:
with x as (
  select a from baz
  union all
  select a from bar
)
select a 
from x
where a=1..gives the error:
Plan("No field named 'x.a'. Valid fields are 'baz.a'.")
Explicitly specifying where x.a gives the same error, so that is resolving correctly?
Writing the query as where baz.a=1 instead gives:
Plan("No field named 'baz.a'. Valid fields are 'x.a'.")
To Reproduce
Steps to reproduce the behavior:
❯ create table bar as select 1 as a;
❯ create table baz as select 1 as a;
❯ with x as (select a from baz union all select a from bar) select a from x;
+---+
| a |
+---+
| 1 |
| 1 |
+---+
❯ with x as (select a from baz union all select a from bar) select a from x where a=1;
Plan("No field named 'x.a'. Valid fields are 'baz.a'.")
Expected behavior
I believe SELECT a FROM x WHERE a=1 should function as if x was a single table containing a column named a, as shown in non-filtered select in the reproduction steps above.
Additional context
This isn't something to do with memory tables; it happens to my Parquet EXTERNAL tables too.
The error messaging here isn't great for my parquet files, which already use dotted notation, like select "address.line1" from address, now we have "address.address.line1".