mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
Merge pull request #41388 from den-crane/bug/optimize_rewrite_sum_if_to_count_if
Disable optimize_rewrite_sum_if_to_count_if by default
This commit is contained in:
commit
5584ef71f6
@ -527,7 +527,7 @@ static constexpr UInt64 operator""_GiB(unsigned long long value)
|
|||||||
M(Bool, describe_extend_object_types, false, "Deduce concrete type of columns of type Object in DESCRIBE query", 0) \
|
M(Bool, describe_extend_object_types, false, "Deduce concrete type of columns of type Object in DESCRIBE query", 0) \
|
||||||
M(Bool, describe_include_subcolumns, false, "If true, subcolumns of all table columns will be included into result of DESCRIBE query", 0) \
|
M(Bool, describe_include_subcolumns, false, "If true, subcolumns of all table columns will be included into result of DESCRIBE query", 0) \
|
||||||
\
|
\
|
||||||
M(Bool, optimize_rewrite_sum_if_to_count_if, true, "Rewrite sumIf() and sum(if()) function countIf() function when logically equivalent", 0) \
|
M(Bool, optimize_rewrite_sum_if_to_count_if, false, "Rewrite sumIf() and sum(if()) function countIf() function when logically equivalent", 0) \
|
||||||
M(UInt64, insert_shard_id, 0, "If non zero, when insert into a distributed table, the data will be inserted into the shard `insert_shard_id` synchronously. Possible values range from 1 to `shards_number` of corresponding distributed table", 0) \
|
M(UInt64, insert_shard_id, 0, "If non zero, when insert into a distributed table, the data will be inserted into the shard `insert_shard_id` synchronously. Possible values range from 1 to `shards_number` of corresponding distributed table", 0) \
|
||||||
\
|
\
|
||||||
M(Bool, collect_hash_table_stats_during_aggregation, true, "Enable collecting hash table statistics to optimize memory allocation", 0) \
|
M(Bool, collect_hash_table_stats_during_aggregation, true, "Enable collecting hash table statistics to optimize memory allocation", 0) \
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
67
|
||||||
|
0 100
|
26
tests/queries/0_stateless/01646_rewrite_sum_if_bug.sql
Normal file
26
tests/queries/0_stateless/01646_rewrite_sum_if_bug.sql
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
DROP TABLE IF EXISTS t;
|
||||||
|
create table t( s String ) Engine=Memory as select arrayJoin (['a','b','c']);
|
||||||
|
|
||||||
|
SELECT round((sum(multiIf(s IN ('a', 'b'), 1, 0)) / count()) * 100) AS r
|
||||||
|
FROM cluster('test_cluster_two_shards', currentDatabase(), t);
|
||||||
|
|
||||||
|
DROP TABLE t;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS test_alias;
|
||||||
|
|
||||||
|
CREATE TABLE test_alias(`a` Int64, `b` Int64, `c` Int64, `day` Date, `rtime` DateTime) ENGINE = Memory
|
||||||
|
as select 0, 0, 0, '2022-01-01', 0 from zeros(10);
|
||||||
|
|
||||||
|
WITH
|
||||||
|
sum(if((a >= 0) AND (b != 100) AND (c = 0), 1, 0)) AS r1,
|
||||||
|
sum(if((a >= 0) AND (b != 100) AND (c > 220), 1, 0)) AS r2
|
||||||
|
SELECT
|
||||||
|
(intDiv(toUInt32(rtime), 20) * 20) * 1000 AS t,
|
||||||
|
(r1 * 100) / (r1 + r2) AS m
|
||||||
|
FROM cluster('test_cluster_two_shards', currentDatabase(), test_alias)
|
||||||
|
WHERE day = '2022-01-01'
|
||||||
|
GROUP BY t
|
||||||
|
ORDER BY t ASC;
|
||||||
|
|
||||||
|
DROP TABLE test_alias;
|
@ -4,6 +4,10 @@ create table m (a int) engine Log;
|
|||||||
|
|
||||||
insert into m values (1);
|
insert into m values (1);
|
||||||
|
|
||||||
|
set optimize_rewrite_sum_if_to_count_if=1;
|
||||||
|
|
||||||
explain syntax select sum(multiIf(a = 1, 1, 0)) from m;
|
explain syntax select sum(multiIf(a = 1, 1, 0)) from m;
|
||||||
|
|
||||||
|
set optimize_rewrite_sum_if_to_count_if=0;
|
||||||
|
|
||||||
drop table m;
|
drop table m;
|
||||||
|
Loading…
Reference in New Issue
Block a user