Proper exception message for wrong number of arguments of CAST

This commit is contained in:
Alexey Milovidov 2020-09-19 22:34:24 +03:00
parent c185db46f9
commit 5a47e64685
3 changed files with 4 additions and 0 deletions

View File

@ -33,6 +33,9 @@ static bool tryExtractConstValueFromCondition(const ASTPtr & condition, bool & v
{
if (const auto * expr_list = function->arguments->as<ASTExpressionList>())
{
if (expr_list->children.size() != 2)
throw Exception("Function CAST must have exactly two arguments", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
const ASTPtr & type_ast = expr_list->children.at(1);
if (const auto * type_literal = type_ast->as<ASTLiteral>())
{

View File

@ -0,0 +1 @@
SELECT if(CAST(NULL), '2.55', NULL) AS x; -- { serverError 42 }