mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #17887 from sundy-li/trivial_count-fix
disable optimize_trivial_count in query with array join
This commit is contained in:
commit
0d6fe7121d
@ -562,7 +562,7 @@ void TreeRewriterResult::collectUsedColumns(const ASTPtr & query, bool is_select
|
||||
/// If we have no information about columns sizes, choose a column of minimum size of its data type.
|
||||
required.insert(ExpressionActions::getSmallestColumn(source_columns));
|
||||
}
|
||||
else if (is_select && metadata_snapshot)
|
||||
else if (is_select && metadata_snapshot && !columns_context.has_array_join)
|
||||
{
|
||||
const auto & partition_desc = metadata_snapshot->getPartitionKey();
|
||||
if (partition_desc.expression)
|
||||
|
@ -7,4 +7,6 @@
|
||||
0
|
||||
2
|
||||
0
|
||||
4
|
||||
6
|
||||
3
|
||||
|
@ -2,7 +2,7 @@ drop table if exists test1;
|
||||
drop table if exists test_tuple;
|
||||
drop table if exists test_two_args;
|
||||
|
||||
create table test1(p DateTime, k int) engine MergeTree partition by toDate(p) order by k;
|
||||
create table test1(p DateTime, k int) engine MergeTree partition by toDate(p) order by k settings index_granularity = 1;
|
||||
insert into test1 values ('2020-09-01 00:01:02', 1), ('2020-09-01 20:01:03', 2), ('2020-09-02 00:01:03', 3);
|
||||
|
||||
set max_rows_to_read = 1;
|
||||
@ -22,7 +22,7 @@ select count() from test1 where toDate(p) > '2020-09-01';
|
||||
-- non-optimized
|
||||
select count() from test1 where toDate(p) >= '2020-09-01' and p <= '2020-09-01 00:00:00';
|
||||
|
||||
create table test_tuple(p DateTime, i int, j int) engine MergeTree partition by (toDate(p), i) order by j;
|
||||
create table test_tuple(p DateTime, i int, j int) engine MergeTree partition by (toDate(p), i) order by j settings index_granularity = 1;
|
||||
|
||||
insert into test_tuple values ('2020-09-01 00:01:02', 1, 2), ('2020-09-01 00:01:03', 2, 3), ('2020-09-02 00:01:03', 3, 4);
|
||||
|
||||
@ -34,8 +34,14 @@ select count() from test_tuple where toDate(p) > '2020-09-01' and i = 1;
|
||||
select count() from test_tuple where i > 1;
|
||||
-- optimized
|
||||
select count() from test_tuple where i < 1;
|
||||
-- non-optimized
|
||||
select count() from test_tuple array join [p,p] as c where toDate(p) = '2020-09-01'; -- { serverError 158; }
|
||||
select count() from test_tuple array join [1,2] as c where toDate(p) = '2020-09-01' settings max_rows_to_read = 4;
|
||||
-- non-optimized
|
||||
select count() from test_tuple array join [1,2,3] as c where toDate(p) = '2020-09-01'; -- { serverError 158; }
|
||||
select count() from test_tuple array join [1,2,3] as c where toDate(p) = '2020-09-01' settings max_rows_to_read = 6;
|
||||
|
||||
create table test_two_args(i int, j int, k int) engine MergeTree partition by i + j order by k;
|
||||
create table test_two_args(i int, j int, k int) engine MergeTree partition by i + j order by k settings index_granularity = 1;
|
||||
|
||||
insert into test_two_args values (1, 2, 3), (2, 1, 3), (0, 3, 4);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user