mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Better exception message in case of wrong number of arguments for function "if" [#CLICKHOUSE-3932]
This commit is contained in:
parent
5637b30556
commit
eee6644a22
@ -423,10 +423,13 @@ void ExpressionAnalyzer::optimizeIfWithConstantConditionImpl(ASTPtr & current_as
|
||||
optimizeIfWithConstantConditionImpl(function_node->arguments, aliases);
|
||||
ASTExpressionList * args = typeid_cast<ASTExpressionList *>(function_node->arguments.get());
|
||||
|
||||
ASTPtr condition_expr = args->children.at(0);
|
||||
ASTPtr then_expr = args->children.at(1);
|
||||
ASTPtr else_expr = args->children.at(2);
|
||||
if (args->children.size() != 3)
|
||||
throw Exception("Wrong number of arguments for function 'if' (" + toString(args->children.size()) + " instead of 3)",
|
||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||
|
||||
ASTPtr condition_expr = args->children[0];
|
||||
ASTPtr then_expr = args->children[1];
|
||||
ASTPtr else_expr = args->children[2];
|
||||
|
||||
bool condition;
|
||||
if (tryExtractConstValueFromCondition(condition_expr, condition))
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,4 @@
|
||||
SELECT if(); -- { serverError 42 }
|
||||
SELECT if(1); -- { serverError 42 }
|
||||
SELECT if(1, 1); -- { serverError 42 }
|
||||
SELECT if(1, 1, 1);
|
Loading…
Reference in New Issue
Block a user