Merge pull request #41189 from kssenii/fix-positional-args

Fix for positional arguments
This commit is contained in:
Alexey Milovidov 2022-09-12 03:21:39 +03:00 committed by GitHub
commit 94d6e9ce7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 3 deletions

View File

@ -1258,9 +1258,6 @@ TreeRewriterResultPtr TreeRewriter::analyzeSelect(
all_source_columns_set.insert(name);
}
normalize(query, result.aliases, all_source_columns_set, select_options.ignore_alias, settings, /* allow_self_aliases = */ true, getContext());
if (getContext()->getSettingsRef().enable_positional_arguments)
{
if (select_query->groupBy())
@ -1280,6 +1277,8 @@ TreeRewriterResultPtr TreeRewriter::analyzeSelect(
}
}
normalize(query, result.aliases, all_source_columns_set, select_options.ignore_alias, settings, /* allow_self_aliases = */ true, getContext());
/// Remove unneeded columns according to 'required_result_columns'.
/// Leave all selected columns in case of DISTINCT; columns that contain arrayJoin function inside.
/// Must be after 'normalizeTree' (after expanding aliases, for aliases not get lost)

View File

@ -117,7 +117,19 @@ select b from (select 5 as a, 'Hello' as b group by a);
Hello
select b from (select 5 as a, 'Hello' as b order by 1);
Hello
drop table if exists tp2;
create table tp2(first_col String, second_col Int32) engine = MergeTree() order by tuple();
select count(*) from (select first_col, count(second_col) from tp2 group by 1);
0
select total from (select first_col, count(second_col) as total from tp2 group by 1);
drop table if exists test;
create table test
(
`id` UInt32,
`time` UInt32,
index `id` (`id`) type set(0) granularity 3,
index `time` (`time`) type minmax granularity 3
) engine = MergeTree()
order by (`time`);
select count(*) as `value`, 0 as `data` from test group by `data`;
drop table test;

View File

@ -49,6 +49,21 @@ select b from (select 5 as a, 'Hello' as b order by a);
select b from (select 5 as a, 'Hello' as b group by a);
select b from (select 5 as a, 'Hello' as b order by 1);
drop table if exists tp2;
create table tp2(first_col String, second_col Int32) engine = MergeTree() order by tuple();
select count(*) from (select first_col, count(second_col) from tp2 group by 1);
select total from (select first_col, count(second_col) as total from tp2 group by 1);
drop table if exists test;
create table test
(
`id` UInt32,
`time` UInt32,
index `id` (`id`) type set(0) granularity 3,
index `time` (`time`) type minmax granularity 3
) engine = MergeTree()
order by (`time`);
select count(*) as `value`, 0 as `data` from test group by `data`;
drop table test;