Merge pull request #66146 from Algunenano/SumIfToCountIfAgainYaySoHappy

Fix issue in SumIfToCountIfVisitor and signed integers
This commit is contained in:
Raúl Marín 2024-07-08 11:15:30 +00:00 committed by GitHub
commit a3d53dc627
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View File

@ -33,7 +33,7 @@ public:
return;
auto * function_node = node->as<FunctionNode>();
if (!function_node || !function_node->isAggregateFunction())
if (!function_node || !function_node->isAggregateFunction() || !function_node->getResultType()->equals(DataTypeUInt64()))
return;
auto function_name = function_node->getFunctionName();

View File

@ -0,0 +1,24 @@
QUERY id: 0
PROJECTION COLUMNS
(sumIf(toInt64(1), 1)) Tuple(Int64)
PROJECTION
LIST id: 1, nodes: 1
FUNCTION id: 2, function_name: tuple, function_type: ordinary, result_type: Tuple(Int64)
ARGUMENTS
LIST id: 3, nodes: 1
FUNCTION id: 4, function_name: sumIf, function_type: aggregate, result_type: Int64
ARGUMENTS
LIST id: 5, nodes: 2
CONSTANT id: 6, constant_value: Int64_1, constant_value_type: Int64
EXPRESSION
FUNCTION id: 7, function_name: toInt64, function_type: ordinary, result_type: Int64
ARGUMENTS
LIST id: 8, nodes: 1
CONSTANT id: 9, constant_value: UInt64_1, constant_value_type: UInt8
CONSTANT id: 10, constant_value: UInt64_1, constant_value_type: UInt8
JOIN TREE
TABLE_FUNCTION id: 11, alias: __table1, table_function_name: numbers
ARGUMENTS
LIST id: 12, nodes: 1
CONSTANT id: 13, constant_value: UInt64_100, constant_value_type: UInt8
SETTINGS optimize_rewrite_sum_if_to_count_if=1

View File

@ -0,0 +1,2 @@
SET allow_experimental_analyzer = 1;
EXPLAIN QUERY TREE SELECT tuple(sumIf(toInt64(1), 1)) FROM numbers(100) settings optimize_rewrite_sum_if_to_count_if=1;