Merge pull request #33889 from kitaisreal/sql-user-defined-functions-invalid-lambda-crash-fix

SQLUserDefinedFunctions invalid lambda additional fixes
This commit is contained in:
Maksim Kita 2022-01-22 12:09:42 +01:00 committed by GitHub
commit 1bc3f086b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -60,11 +60,17 @@ void InterpreterCreateFunctionQuery::validateFunction(ASTPtr function, const Str
auto & lambda_function = function->as<ASTFunction &>();
auto & lambda_function_expression_list = lambda_function.arguments->children;
const auto & tuple_function_arguments = lambda_function_expression_list.at(0)->as<ASTFunction &>();
const ASTFunction * tuple_function_arguments = nullptr;
if (!lambda_function_expression_list.empty())
tuple_function_arguments = lambda_function_expression_list[0]->as<ASTFunction>();
if (!tuple_function_arguments || !tuple_function_arguments->arguments)
throw Exception(ErrorCodes::UNSUPPORTED_METHOD, "Lambda must have arguments");
std::unordered_set<String> arguments;
for (const auto & argument : tuple_function_arguments.arguments->children)
for (const auto & argument : tuple_function_arguments->arguments->children)
{
const auto * argument_identifier = argument->as<ASTIdentifier>();

View File

@ -1 +1,3 @@
CREATE FUNCTION 02181_invalid_lambda AS lambda(((x * 2) AS x_doubled) + x_doubled); --{serverError 1}
CREATE FUNCTION 02181_invalid_lambda AS lambda(x); --{serverError 1}
CREATE FUNCTION 02181_invalid_lambda AS lambda(); --{serverError 1}