Merge pull request #45133 from ClickHouse/fix-additinal-tables-filter-with-count-projection

Fix additional_table_filters with minmax/count projection.
This commit is contained in:
Nikolai Kochetov 2023-01-11 12:25:40 +01:00 committed by GitHub
commit d0c1079242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -6052,6 +6052,10 @@ std::optional<ProjectionCandidate> MergeTreeData::getQueryProcessingStageWithAgg
if (settings.parallel_replicas_count > 1 || settings.max_parallel_replicas > 1) if (settings.parallel_replicas_count > 1 || settings.max_parallel_replicas > 1)
return std::nullopt; 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 query_ptr = query_info.original_query;
auto * select_query = query_ptr->as<ASTSelectQuery>(); auto * select_query = query_ptr->as<ASTSelectQuery>();
if (!select_query) 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'}; SELECT count(), min(a), max(a) FROM t SETTINGS additional_table_filters = {'t' : '0'};
DROP TABLE t; 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;