Fix projections with JOIN alias columns

This commit is contained in:
Amos Bird 2021-10-16 23:07:55 +08:00
parent 8986de7e50
commit 240895fba7
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 8 additions and 1 deletions

View File

@ -890,9 +890,10 @@ static std::unique_ptr<QueryPlan> buildJoinedPlan(
* - in the addExternalStorage function, the JOIN (SELECT ...) subquery is replaced with JOIN _data1,
* in the subquery_for_set object this subquery is exposed as source and the temporary table _data1 as the `table`.
* - this function shows the expression JOIN _data1.
* - JOIN tables will need aliases to correctly resolve USING clause.
*/
auto interpreter = interpretSubquery(
join_element.table_expression, context, original_right_columns, query_options.copy().setWithAllColumns());
join_element.table_expression, context, original_right_columns, query_options.copy().setWithAllColumns().ignoreAlias(false));
auto joined_plan = std::make_unique<QueryPlan>();
interpreter->buildQueryPlan(*joined_plan);
{

View File

@ -0,0 +1,6 @@
drop table if exists t;
create table t (s UInt16, l UInt16, projection p (select s, l order by l)) engine MergeTree order by s;
set allow_experimental_projection_optimization=1;
select s from t join (select toUInt16(1) as s) x using (s);