mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #43118 from kitaisreal/analyzer-aggregation-crash-fix
Analyzer aggregation crash fix
This commit is contained in:
commit
ebde28bc50
@ -33,18 +33,27 @@ public:
|
||||
|
||||
if (function_node->getFunctionName() == "count" && !first_argument_constant_literal.isNull())
|
||||
{
|
||||
resolveAsCountAggregateFunction(*function_node);
|
||||
function_node->getArguments().getNodes().clear();
|
||||
}
|
||||
else if (function_node->getFunctionName() == "sum" && first_argument_constant_literal.getType() == Field::Types::UInt64 &&
|
||||
else if (function_node->getFunctionName() == "sum" &&
|
||||
first_argument_constant_literal.getType() == Field::Types::UInt64 &&
|
||||
first_argument_constant_literal.get<UInt64>() == 1)
|
||||
{
|
||||
auto result_type = function_node->getResultType();
|
||||
AggregateFunctionProperties properties;
|
||||
auto aggregate_function = AggregateFunctionFactory::instance().get("count", {}, {}, properties);
|
||||
function_node->resolveAsAggregateFunction(std::move(aggregate_function), std::move(result_type));
|
||||
resolveAsCountAggregateFunction(*function_node);
|
||||
function_node->getArguments().getNodes().clear();
|
||||
}
|
||||
}
|
||||
private:
|
||||
static inline void resolveAsCountAggregateFunction(FunctionNode & function_node)
|
||||
{
|
||||
auto function_result_type = function_node.getResultType();
|
||||
|
||||
AggregateFunctionProperties properties;
|
||||
auto aggregate_function = AggregateFunctionFactory::instance().get("count", {}, {}, properties);
|
||||
|
||||
function_node.resolveAsAggregateFunction(std::move(aggregate_function), std::move(function_result_type));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,2 @@
|
||||
10 123456789
|
||||
10 123456789
|
@ -0,0 +1,13 @@
|
||||
SET allow_experimental_analyzer = 1;
|
||||
SET compile_aggregate_expressions = 1;
|
||||
SET min_count_to_compile_aggregate_expression = 0;
|
||||
|
||||
DROP TABLE IF EXISTS lc_00906__fuzz_46;
|
||||
CREATE TABLE lc_00906__fuzz_46 (`b` Int64) ENGINE = MergeTree ORDER BY b;
|
||||
INSERT INTO lc_00906__fuzz_46 SELECT '0123456789' FROM numbers(10);
|
||||
|
||||
SELECT count(3.4028234663852886e38), b FROM lc_00906__fuzz_46 GROUP BY b;
|
||||
|
||||
SELECT count(1), b FROM lc_00906__fuzz_46 GROUP BY b;
|
||||
|
||||
DROP TABLE lc_00906__fuzz_46;
|
Loading…
Reference in New Issue
Block a user