mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Fix order and reference files
This commit is contained in:
parent
93be6c4a2a
commit
052713db3b
@ -259,8 +259,6 @@ void addQueryTreePasses(QueryTreePassManager & manager, bool only_analyze)
|
|||||||
manager.addPass(std::make_unique<RewriteSumFunctionWithSumAndCountPass>());
|
manager.addPass(std::make_unique<RewriteSumFunctionWithSumAndCountPass>());
|
||||||
manager.addPass(std::make_unique<CountDistinctPass>());
|
manager.addPass(std::make_unique<CountDistinctPass>());
|
||||||
manager.addPass(std::make_unique<UniqToCountPass>());
|
manager.addPass(std::make_unique<UniqToCountPass>());
|
||||||
manager.addPass(std::make_unique<RewriteAggregateFunctionWithIfPass>());
|
|
||||||
manager.addPass(std::make_unique<SumIfToCountIfPass>());
|
|
||||||
manager.addPass(std::make_unique<RewriteArrayExistsToHasPass>());
|
manager.addPass(std::make_unique<RewriteArrayExistsToHasPass>());
|
||||||
manager.addPass(std::make_unique<NormalizeCountVariantsPass>());
|
manager.addPass(std::make_unique<NormalizeCountVariantsPass>());
|
||||||
|
|
||||||
@ -277,9 +275,12 @@ void addQueryTreePasses(QueryTreePassManager & manager, bool only_analyze)
|
|||||||
manager.addPass(std::make_unique<OptimizeGroupByFunctionKeysPass>());
|
manager.addPass(std::make_unique<OptimizeGroupByFunctionKeysPass>());
|
||||||
manager.addPass(std::make_unique<OptimizeGroupByInjectiveFunctionsPass>());
|
manager.addPass(std::make_unique<OptimizeGroupByInjectiveFunctionsPass>());
|
||||||
|
|
||||||
|
/// The order here is important as we want to keep collapsing in order
|
||||||
manager.addPass(std::make_unique<MultiIfToIfPass>());
|
manager.addPass(std::make_unique<MultiIfToIfPass>());
|
||||||
manager.addPass(std::make_unique<IfConstantConditionPass>());
|
manager.addPass(std::make_unique<IfConstantConditionPass>());
|
||||||
manager.addPass(std::make_unique<IfChainToMultiIfPass>());
|
manager.addPass(std::make_unique<IfChainToMultiIfPass>());
|
||||||
|
manager.addPass(std::make_unique<RewriteAggregateFunctionWithIfPass>());
|
||||||
|
manager.addPass(std::make_unique<SumIfToCountIfPass>());
|
||||||
|
|
||||||
manager.addPass(std::make_unique<ComparisonTupleEliminationPass>());
|
manager.addPass(std::make_unique<ComparisonTupleEliminationPass>());
|
||||||
|
|
||||||
|
@ -10,12 +10,6 @@
|
|||||||
50
|
50
|
||||||
50 50 50 1 0
|
50 50 50 1 0
|
||||||
50
|
50
|
||||||
SELECT sumIf(123, (number % 2) = 0)
|
|
||||||
FROM numbers(100)
|
|
||||||
SELECT sum(if((number % 2) = 0, 123, 0))
|
|
||||||
FROM numbers(100)
|
|
||||||
SELECT sum(if((number % 2) = 0, 0, 123))
|
|
||||||
FROM numbers(100)
|
|
||||||
0
|
0
|
||||||
0 0 1
|
0 0 1
|
||||||
0
|
0
|
||||||
@ -28,12 +22,6 @@ FROM numbers(100)
|
|||||||
50
|
50
|
||||||
50 50 50 1 0
|
50 50 50 1 0
|
||||||
50
|
50
|
||||||
SELECT 123 * countIf((number % 2) = 0)
|
|
||||||
FROM numbers(100)
|
|
||||||
SELECT 123 * countIf((number % 2) = 0)
|
|
||||||
FROM numbers(100)
|
|
||||||
SELECT 123 * countIf(NOT ((number % 2) = 0))
|
|
||||||
FROM numbers(100)
|
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
PROJECTION COLUMNS
|
PROJECTION COLUMNS
|
||||||
sumIf(123, equals(modulo(number, 2), 0)) UInt64
|
sumIf(123, equals(modulo(number, 2), 0)) UInt64
|
||||||
|
@ -16,10 +16,6 @@ SELECT sum(if(number % 2 == 0, 0, 1)) FROM numbers(100);
|
|||||||
SELECT sum(if(number % 2 == 0 as cond_expr, 0 as zero_expr, 1 as one_expr) as if_expr), sum(cond_expr), sum(if_expr), one_expr, zero_expr FROM numbers(100);
|
SELECT sum(if(number % 2 == 0 as cond_expr, 0 as zero_expr, 1 as one_expr) as if_expr), sum(cond_expr), sum(if_expr), one_expr, zero_expr FROM numbers(100);
|
||||||
SELECT countIf(number % 2 != 0) FROM numbers(100);
|
SELECT countIf(number % 2 != 0) FROM numbers(100);
|
||||||
|
|
||||||
EXPLAIN SYNTAX SELECT sumIf(123, number % 2 == 0) FROM numbers(100);
|
|
||||||
EXPLAIN SYNTAX SELECT sum(if(number % 2 == 0, 123, 0)) FROM numbers(100);
|
|
||||||
EXPLAIN SYNTAX SELECT sum(if(number % 2 == 0, 0, 123)) FROM numbers(100);
|
|
||||||
|
|
||||||
SET optimize_rewrite_sum_if_to_count_if = 1;
|
SET optimize_rewrite_sum_if_to_count_if = 1;
|
||||||
|
|
||||||
SELECT sumIf(1, number % 2 > 2) FROM numbers(100);
|
SELECT sumIf(1, number % 2 > 2) FROM numbers(100);
|
||||||
@ -38,12 +34,8 @@ SELECT sum(if(number % 2 == 0, 0, 1)) FROM numbers(100);
|
|||||||
SELECT sum(if(number % 2 == 0 as cond_expr, 0 as zero_expr, 1 as one_expr) as if_expr), sum(cond_expr), sum(if_expr), one_expr, zero_expr FROM numbers(100);
|
SELECT sum(if(number % 2 == 0 as cond_expr, 0 as zero_expr, 1 as one_expr) as if_expr), sum(cond_expr), sum(if_expr), one_expr, zero_expr FROM numbers(100);
|
||||||
SELECT countIf(number % 2 != 0) FROM numbers(100);
|
SELECT countIf(number % 2 != 0) FROM numbers(100);
|
||||||
|
|
||||||
EXPLAIN SYNTAX SELECT sumIf(123, number % 2 == 0) FROM numbers(100);
|
|
||||||
EXPLAIN SYNTAX SELECT sum(if(number % 2 == 0, 123, 0)) FROM numbers(100);
|
|
||||||
EXPLAIN SYNTAX SELECT sum(if(number % 2 == 0, 0, 123)) FROM numbers(100);
|
|
||||||
|
|
||||||
set allow_experimental_analyzer = true;
|
set allow_experimental_analyzer = true;
|
||||||
|
|
||||||
EXPLAIN QUERY TREE run_passes=1 SELECT sumIf(123, number % 2 == 0) FROM numbers(100);
|
EXPLAIN QUERY TREE run_passes=1 SELECT sumIf(123, number % 2 == 0) FROM numbers(100);
|
||||||
EXPLAIN QUERY TREE run_passes=1 SELECT sum(if(number % 2 == 0, 123, 0)) FROM numbers(100);
|
EXPLAIN QUERY TREE run_passes=1 SELECT sum(if(number % 2 == 0, 123, 0)) FROM numbers(100);
|
||||||
EXPLAIN QUERY TREE run_passes=1 SELECT sum(if(number % 2 == 0, 0, 123)) FROM numbers(100);
|
EXPLAIN QUERY TREE run_passes=1 SELECT sum(if(number % 2 == 0, 0, 123)) FROM numbers(100);
|
||||||
|
@ -1,2 +1,15 @@
|
|||||||
SELECT countIf(a = 1)
|
QUERY id: 0
|
||||||
FROM m
|
PROJECTION COLUMNS
|
||||||
|
sum(multiIf(equals(a, 1), 1, 0)) UInt64
|
||||||
|
PROJECTION
|
||||||
|
LIST id: 1, nodes: 1
|
||||||
|
FUNCTION id: 2, function_name: countIf, function_type: aggregate, result_type: UInt64
|
||||||
|
ARGUMENTS
|
||||||
|
LIST id: 3, nodes: 1
|
||||||
|
FUNCTION id: 4, function_name: equals, function_type: ordinary, result_type: UInt8
|
||||||
|
ARGUMENTS
|
||||||
|
LIST id: 5, nodes: 2
|
||||||
|
COLUMN id: 6, column_name: a, result_type: Int32, source_id: 7
|
||||||
|
CONSTANT id: 8, constant_value: UInt64_1, constant_value_type: UInt8
|
||||||
|
JOIN TREE
|
||||||
|
TABLE id: 7, alias: __table1, table_name: default.m
|
||||||
|
@ -4,10 +4,8 @@ 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;
|
set allow_experimental_analyzer = true, optimize_rewrite_sum_if_to_count_if=1;
|
||||||
|
|
||||||
explain syntax select sum(multiIf(a = 1, 1, 0)) from m;
|
EXPLAIN QUERY TREE select sum(multiIf(a = 1, 1, 0)) from m;
|
||||||
|
|
||||||
set optimize_rewrite_sum_if_to_count_if=0;
|
|
||||||
|
|
||||||
drop table m;
|
drop table m;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
1024
|
1024
|
||||||
0
|
1024
|
||||||
1024
|
1024
|
||||||
|
Loading…
Reference in New Issue
Block a user