Bug: prefer table names defined by CTE
Summary
For the case, the last query has cte named source, ideally, the query SELECT * FROM source should use the table of cte, but it uses the table source defined before.
create table source(a int);
insert into source values(1);
select * from source;
select * from (WITH source AS (select 1 as e) SELECT * FROM source) A, (WITH source AS (select 2 as e) SELECT * FROM source) B;
@xudong963 can i work on this issue?
@BohuTANG i'm new to this code base if possbile can you help me with the start or some idea about the files i should look into.
@Vasanth-96 Hi, this guide is helpful https://docs.databend.com/guides/community/contributor/good-pr
You can read the file: https://github.com/datafuselabs/databend/blob/main/src/query/sql/src/planner/binder/bind_table_reference/bind_table.rs#L36.
The issue has been solved by https://github.com/datafuselabs/databend/pull/15941