Merge pull request #15029 from ClickHouse/cast-single-argument

Proper exception message for wrong number of arguments of CAST
This commit is contained in:
alexey-milovidov 2020-09-20 19:03:47 +03:00 committed by GitHub
commit 3f5d7843f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 }