Fix additional_table_filters with minmax/count projection.

This commit is contained in:
Nikolai Kochetov 2023-01-10 17:32:26 +00:00
parent 0a60fe6e60
commit 9a81f27fb2
3 changed files with 11 additions and 0 deletions

View File

@ -5960,6 +5960,10 @@ std::optional<ProjectionCandidate> MergeTreeData::getQueryProcessingStageWithAgg
if (settings.parallel_replicas_count > 1 || settings.max_parallel_replicas > 1)
return std::nullopt;
/// Cannot use projections in case of additional filter.
if (query_info.additional_filter_ast)
return std::nullopt;
auto query_ptr = query_info.original_query;
auto * select_query = query_ptr->as<ASTSelectQuery>();
if (!select_query)

View File

@ -7,3 +7,9 @@ INSERT INTO t SELECT number % 10, number FROM numbers(10000);
SELECT count(), min(a), max(a) FROM t SETTINGS additional_table_filters = {'t' : '0'};
DROP TABLE t;
drop table if exists atf_p;
create table atf_p (x UInt64) engine = MergeTree order by tuple();
insert into atf_p select number from numbers(10);
select count() from atf_p settings additional_table_filters = {'atf_p': 'x <= 2'};
drop table atf_p;