From aabe52e3e95b6ad99ca28de4081e2820c249bb5a Mon Sep 17 00:00:00 2001 From: hexiaoting Date: Mon, 11 Oct 2021 10:39:55 +0800 Subject: [PATCH] Fix bug for quantile fusion --- src/Interpreters/GatherFunctionQuantileVisitor.cpp | 2 +- .../0_stateless/01956_fuse_quantile_optimization.reference | 1 + tests/queries/0_stateless/01956_fuse_quantile_optimization.sql | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Interpreters/GatherFunctionQuantileVisitor.cpp b/src/Interpreters/GatherFunctionQuantileVisitor.cpp index ec3866ba0c0..3eb474c271c 100644 --- a/src/Interpreters/GatherFunctionQuantileVisitor.cpp +++ b/src/Interpreters/GatherFunctionQuantileVisitor.cpp @@ -47,7 +47,7 @@ void GatherFunctionQuantileData::visit(ASTFunction & function, ASTPtr & ast) void GatherFunctionQuantileData::FuseQuantileAggregatesData::addFuncNode(ASTPtr & ast) { const auto * func = ast->as(); - if (!func) + if (!func || func->parameters == nullptr) return; const auto & arguments = func->arguments->children; diff --git a/tests/queries/0_stateless/01956_fuse_quantile_optimization.reference b/tests/queries/0_stateless/01956_fuse_quantile_optimization.reference index defad422cad..d4cb1477ed6 100644 --- a/tests/queries/0_stateless/01956_fuse_quantile_optimization.reference +++ b/tests/queries/0_stateless/01956_fuse_quantile_optimization.reference @@ -95,3 +95,4 @@ FROM FROM numbers(10) ) GROUP BY b +1 1 1 diff --git a/tests/queries/0_stateless/01956_fuse_quantile_optimization.sql b/tests/queries/0_stateless/01956_fuse_quantile_optimization.sql index 2a97c60882c..a4729e89755 100644 --- a/tests/queries/0_stateless/01956_fuse_quantile_optimization.sql +++ b/tests/queries/0_stateless/01956_fuse_quantile_optimization.sql @@ -71,3 +71,6 @@ SELECT quantileTimingWeighted([[[[['-214748364.8'], NULL]], [[[quantileTimingWei SELECT quantileTimingWeighted([quantileTimingWeighted(0.5)(1, 1)])(1, 1); -- { serverError ILLEGAL_AGGREGATION } DROP TABLE datetime; + +SET optimize_syntax_fuse_functions = 1; +SELECT quantile(1 AS a), quantile(a AS b), quantile(b AS c);