disable optimize_rewrite_sum_if_to_count_if by default

This commit is contained in:
Denny Crane 2022-09-15 15:30:24 -03:00
parent fac1bf224e
commit 7cfdfbe787
3 changed files with 29 additions and 1 deletions

View File

@ -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_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(Bool, collect_hash_table_stats_during_aggregation, true, "Enable collecting hash table statistics to optimize memory allocation", 0) \

View File

@ -0,0 +1,2 @@
67
0 100

View 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;