Merge pull request #39444 from amosbird/fix-trivial-count-opt-1

Fix trivial count optimization with array join
This commit is contained in:
Maksim Kita 2022-07-21 16:35:49 +02:00 committed by GitHub
commit 82fc7375dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -1016,7 +1016,7 @@ void TreeRewriterResult::collectUsedColumns(const ASTPtr & query, bool is_select
has_explicit_columns = !required.empty();
if (is_select && !has_explicit_columns)
{
optimize_trivial_count = true;
optimize_trivial_count = !columns_context.has_array_join;
/// You need to read at least one column to find the number of rows.
/// We will find a column with minimum <compressed_size, type_size, uncompressed_size>.

View File

@ -0,0 +1,9 @@
drop table if exists t;
create table t(id UInt32) engine MergeTree order by id;
insert into t values (1);
select count() from t array join range(2) as a settings optimize_trivial_count_query = 1;
drop table t;