mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 12:32:04 +00:00
fix core
This commit is contained in:
parent
7f3114d806
commit
952058e69e
@ -43,7 +43,7 @@ public:
|
||||
return;
|
||||
|
||||
auto lower_name = Poco::toLower(function_node->getFunctionName());
|
||||
auto & if_arguments_nodes = if_node->getArguments().getNodes();
|
||||
auto if_arguments_nodes = if_node->getArguments().getNodes();
|
||||
auto * first_const_node = if_arguments_nodes[1]->as<ConstantNode>();
|
||||
auto * second_const_node = if_arguments_nodes[2]->as<ConstantNode>();
|
||||
if (second_const_node)
|
||||
@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
else if (first_const_node)
|
||||
{
|
||||
const auto & first_const_value = first_const_node->getValue();
|
||||
const auto & first_const_value = first_const_node->getValue();
|
||||
if (first_const_value.isNull()
|
||||
|| (lower_name == "sum" && isInt64OrUInt64FieldType(first_const_value.getType()) && first_const_value.get<UInt64>() == 0))
|
||||
{
|
||||
@ -72,7 +72,7 @@ public:
|
||||
auto not_function = std::make_shared<FunctionNode>("not");
|
||||
auto & not_function_arguments = not_function->getArguments().getNodes();
|
||||
not_function_arguments.push_back(std::move(if_arguments_nodes[0]));
|
||||
not_function->resolveAsFunction(FunctionFactory::instance().get("not", context)->build(not_function->getArgumentTypes()));
|
||||
not_function->resolveAsFunction(FunctionFactory::instance().get("not", context)->build(not_function->getArgumentColumns()));
|
||||
|
||||
function_arguments_nodes.resize(2);
|
||||
function_arguments_nodes[0] = std::move(if_arguments_nodes[2]);
|
||||
|
@ -30,19 +30,177 @@ SELECT quantilesIf(0.5, 0.9, 0.99)(number, number % 2)
|
||||
FROM numbers(100)
|
||||
SELECT quantilesIf(0.5, 0.9, 0.99)(number, NOT (number % 2))
|
||||
FROM numbers(100)
|
||||
SELECT sumIf(number, number % 2)
|
||||
FROM numbers(100)
|
||||
SELECT sumIf(number, NOT (number % 2))
|
||||
FROM numbers(100)
|
||||
SELECT sumIf(number, number % 2)
|
||||
FROM numbers(100)
|
||||
SELECT sumIf(number, NOT (number % 2))
|
||||
FROM numbers(100)
|
||||
SELECT avgIf(number, number % 2)
|
||||
FROM numbers(100)
|
||||
SELECT avgIf(number, NOT (number % 2))
|
||||
FROM numbers(100)
|
||||
SELECT quantilesIf(0.5, 0.9, 0.99)(number, number % 2)
|
||||
FROM numbers(100)
|
||||
SELECT quantilesIf(0.5, 0.9, 0.99)(number, NOT (number % 2))
|
||||
FROM numbers(100)
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
sum(if(modulo(number, 2), number, 0)) UInt64
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 1
|
||||
FUNCTION id: 2, function_name: sumIf, function_type: aggregate, result_type: UInt64
|
||||
ARGUMENTS
|
||||
LIST id: 3, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
FUNCTION id: 6, function_name: modulo, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 7, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
CONSTANT id: 8, constant_value: UInt64_2, constant_value_type: UInt8
|
||||
JOIN TREE
|
||||
TABLE_FUNCTION id: 5, table_function_name: numbers
|
||||
ARGUMENTS
|
||||
LIST id: 9, nodes: 1
|
||||
CONSTANT id: 10, constant_value: UInt64_100, constant_value_type: UInt8
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
sum(if(modulo(number, 2), 0, number)) UInt64
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 1
|
||||
FUNCTION id: 2, function_name: sumIf, function_type: aggregate, result_type: UInt64
|
||||
ARGUMENTS
|
||||
LIST id: 3, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
FUNCTION id: 6, function_name: not, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 7, nodes: 1
|
||||
FUNCTION id: 8, function_name: modulo, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 9, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
CONSTANT id: 10, constant_value: UInt64_2, constant_value_type: UInt8
|
||||
JOIN TREE
|
||||
TABLE_FUNCTION id: 5, table_function_name: numbers
|
||||
ARGUMENTS
|
||||
LIST id: 11, nodes: 1
|
||||
CONSTANT id: 12, constant_value: UInt64_100, constant_value_type: UInt8
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
sum(if(modulo(number, 2), number, NULL)) Nullable(UInt64)
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 1
|
||||
FUNCTION id: 2, function_name: sumIf, function_type: aggregate, result_type: UInt64
|
||||
ARGUMENTS
|
||||
LIST id: 3, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
FUNCTION id: 6, function_name: modulo, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 7, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
CONSTANT id: 8, constant_value: UInt64_2, constant_value_type: UInt8
|
||||
JOIN TREE
|
||||
TABLE_FUNCTION id: 5, table_function_name: numbers
|
||||
ARGUMENTS
|
||||
LIST id: 9, nodes: 1
|
||||
CONSTANT id: 10, constant_value: UInt64_100, constant_value_type: UInt8
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
sum(if(modulo(number, 2), NULL, number)) Nullable(UInt64)
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 1
|
||||
FUNCTION id: 2, function_name: sumIf, function_type: aggregate, result_type: UInt64
|
||||
ARGUMENTS
|
||||
LIST id: 3, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
FUNCTION id: 6, function_name: not, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 7, nodes: 1
|
||||
FUNCTION id: 8, function_name: modulo, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 9, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
CONSTANT id: 10, constant_value: UInt64_2, constant_value_type: UInt8
|
||||
JOIN TREE
|
||||
TABLE_FUNCTION id: 5, table_function_name: numbers
|
||||
ARGUMENTS
|
||||
LIST id: 11, nodes: 1
|
||||
CONSTANT id: 12, constant_value: UInt64_100, constant_value_type: UInt8
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
avg(if(modulo(number, 2), number, NULL)) Nullable(Float64)
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 1
|
||||
FUNCTION id: 2, function_name: avgIf, function_type: aggregate, result_type: Float64
|
||||
ARGUMENTS
|
||||
LIST id: 3, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
FUNCTION id: 6, function_name: modulo, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 7, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
CONSTANT id: 8, constant_value: UInt64_2, constant_value_type: UInt8
|
||||
JOIN TREE
|
||||
TABLE_FUNCTION id: 5, table_function_name: numbers
|
||||
ARGUMENTS
|
||||
LIST id: 9, nodes: 1
|
||||
CONSTANT id: 10, constant_value: UInt64_100, constant_value_type: UInt8
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
avg(if(modulo(number, 2), NULL, number)) Nullable(Float64)
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 1
|
||||
FUNCTION id: 2, function_name: avgIf, function_type: aggregate, result_type: Float64
|
||||
ARGUMENTS
|
||||
LIST id: 3, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
FUNCTION id: 6, function_name: not, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 7, nodes: 1
|
||||
FUNCTION id: 8, function_name: modulo, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 9, nodes: 2
|
||||
COLUMN id: 4, column_name: number, result_type: UInt64, source_id: 5
|
||||
CONSTANT id: 10, constant_value: UInt64_2, constant_value_type: UInt8
|
||||
JOIN TREE
|
||||
TABLE_FUNCTION id: 5, table_function_name: numbers
|
||||
ARGUMENTS
|
||||
LIST id: 11, nodes: 1
|
||||
CONSTANT id: 12, constant_value: UInt64_100, constant_value_type: UInt8
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
quantiles(0.5, 0.9, 0.99)(if(modulo(number, 2), number, NULL)) Array(Float64)
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 1
|
||||
FUNCTION id: 2, function_name: quantilesIf, function_type: aggregate, result_type: Array(Float64)
|
||||
PARAMETERS
|
||||
LIST id: 3, nodes: 3
|
||||
CONSTANT id: 4, constant_value: Float64_0.5, constant_value_type: Float64
|
||||
CONSTANT id: 5, constant_value: Float64_0.9, constant_value_type: Float64
|
||||
CONSTANT id: 6, constant_value: Float64_0.99, constant_value_type: Float64
|
||||
ARGUMENTS
|
||||
LIST id: 7, nodes: 2
|
||||
COLUMN id: 8, column_name: number, result_type: UInt64, source_id: 9
|
||||
FUNCTION id: 10, function_name: modulo, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 11, nodes: 2
|
||||
COLUMN id: 8, column_name: number, result_type: UInt64, source_id: 9
|
||||
CONSTANT id: 12, constant_value: UInt64_2, constant_value_type: UInt8
|
||||
JOIN TREE
|
||||
TABLE_FUNCTION id: 9, table_function_name: numbers
|
||||
ARGUMENTS
|
||||
LIST id: 13, nodes: 1
|
||||
CONSTANT id: 14, constant_value: UInt64_100, constant_value_type: UInt8
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
quantiles(0.5, 0.9, 0.99)(if(modulo(number, 2), NULL, number)) Array(Float64)
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 1
|
||||
FUNCTION id: 2, function_name: quantilesIf, function_type: aggregate, result_type: Array(Float64)
|
||||
PARAMETERS
|
||||
LIST id: 3, nodes: 3
|
||||
CONSTANT id: 4, constant_value: Float64_0.5, constant_value_type: Float64
|
||||
CONSTANT id: 5, constant_value: Float64_0.9, constant_value_type: Float64
|
||||
CONSTANT id: 6, constant_value: Float64_0.99, constant_value_type: Float64
|
||||
ARGUMENTS
|
||||
LIST id: 7, nodes: 2
|
||||
COLUMN id: 8, column_name: number, result_type: UInt64, source_id: 9
|
||||
FUNCTION id: 10, function_name: not, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 11, nodes: 1
|
||||
FUNCTION id: 12, function_name: modulo, function_type: ordinary, result_type: UInt8
|
||||
ARGUMENTS
|
||||
LIST id: 13, nodes: 2
|
||||
COLUMN id: 8, column_name: number, result_type: UInt64, source_id: 9
|
||||
CONSTANT id: 14, constant_value: UInt64_2, constant_value_type: UInt8
|
||||
JOIN TREE
|
||||
TABLE_FUNCTION id: 9, table_function_name: numbers
|
||||
ARGUMENTS
|
||||
LIST id: 15, nodes: 1
|
||||
CONSTANT id: 16, constant_value: UInt64_100, constant_value_type: UInt8
|
||||
|
@ -28,14 +28,14 @@ explain syntax select quantiles(0.5, 0.9, 0.99)(if(number % 2, null, number)) fr
|
||||
|
||||
set allow_experimental_analyzer = true;
|
||||
|
||||
explain syntax select sum(if(number % 2, number, 0)) from numbers(100);
|
||||
explain syntax select sum(if(number % 2, 0, number)) from numbers(100);
|
||||
EXPLAIN QUERY TREE run_passes = 1 select sum(if(number % 2, number, 0)) from numbers(100);
|
||||
EXPLAIN QUERY TREE run_passes = 1 select sum(if(number % 2, 0, number)) from numbers(100);
|
||||
|
||||
explain syntax select sum(if(number % 2, number, null)) from numbers(100);
|
||||
explain syntax select sum(if(number % 2, null, number)) from numbers(100);
|
||||
EXPLAIN QUERY TREE run_passes = 1 select sum(if(number % 2, number, null)) from numbers(100);
|
||||
EXPLAIN QUERY TREE run_passes = 1 select sum(if(number % 2, null, number)) from numbers(100);
|
||||
|
||||
explain syntax select avg(if(number % 2, number, null)) from numbers(100);
|
||||
explain syntax select avg(if(number % 2, null, number)) from numbers(100);
|
||||
EXPLAIN QUERY TREE run_passes = 1 select avg(if(number % 2, number, null)) from numbers(100);
|
||||
EXPLAIN QUERY TREE run_passes = 1 select avg(if(number % 2, null, number)) from numbers(100);
|
||||
|
||||
explain syntax select quantiles(0.5, 0.9, 0.99)(if(number % 2, number, null)) from numbers(100);
|
||||
explain syntax select quantiles(0.5, 0.9, 0.99)(if(number % 2, null, number)) from numbers(100);
|
||||
EXPLAIN QUERY TREE run_passes = 1 select quantiles(0.5, 0.9, 0.99)(if(number % 2, number, null)) from numbers(100);
|
||||
EXPLAIN QUERY TREE run_passes = 1 select quantiles(0.5, 0.9, 0.99)(if(number % 2, null, number)) from numbers(100);
|
||||
|
Loading…
Reference in New Issue
Block a user