From a6296912f355f3be682fb885b2626ccbe22ce97e Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 12 Jan 2021 22:58:54 +0300 Subject: [PATCH] Fix incomplete code --- src/Interpreters/RewriteAnyFunctionVisitor.cpp | 3 +++ tests/queries/0_stateless/01650_any_null_if.sql | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/Interpreters/RewriteAnyFunctionVisitor.cpp b/src/Interpreters/RewriteAnyFunctionVisitor.cpp index e8f05962862..f7c128a5749 100644 --- a/src/Interpreters/RewriteAnyFunctionVisitor.cpp +++ b/src/Interpreters/RewriteAnyFunctionVisitor.cpp @@ -78,6 +78,9 @@ void RewriteAnyFunctionMatcher::visit(const ASTFunction & func, ASTPtr & ast, Da auto & func_arguments = func.arguments->children; + if (func_arguments.size() != 1) + return; + const auto * first_arg_func = func_arguments[0]->as(); if (!first_arg_func || first_arg_func->arguments->children.empty()) return; diff --git a/tests/queries/0_stateless/01650_any_null_if.sql b/tests/queries/0_stateless/01650_any_null_if.sql index 487a42cf578..17f57e92032 100644 --- a/tests/queries/0_stateless/01650_any_null_if.sql +++ b/tests/queries/0_stateless/01650_any_null_if.sql @@ -1 +1,6 @@ SELECT any(nullIf(s, '')) FROM (SELECT arrayJoin(['', 'Hello']) AS s); + +SET optimize_move_functions_out_of_any = 0; +EXPLAIN SYNTAX select any(nullIf('', ''), 'some text'); -- { serverError 42 } +SET optimize_move_functions_out_of_any = 1; +EXPLAIN SYNTAX select any(nullIf('', ''), 'some text'); -- { serverError 42 }