Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parametric UDFs #51964

Merged
merged 2 commits into from Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/Analyzer/Passes/QueryAnalysisPass.cpp
Expand Up @@ -116,7 +116,6 @@ namespace ErrorCodes
extern const int UNKNOWN_TABLE;
extern const int ILLEGAL_COLUMN;
extern const int NUMBER_OF_COLUMNS_DOESNT_MATCH;
extern const int FUNCTION_CANNOT_HAVE_PARAMETERS;
}

/** Query analyzer implementation overview. Please check documentation in QueryAnalysisPass.h first.
Expand Down Expand Up @@ -4897,11 +4896,6 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
lambda_expression_untyped->formatASTForErrorMessage(),
scope.scope_node->formatASTForErrorMessage());

if (!parameters.empty())
{
throw Exception(ErrorCodes::FUNCTION_CANNOT_HAVE_PARAMETERS, "Function {} is not parametric", function_node.formatASTForErrorMessage());
}

auto lambda_expression_clone = lambda_expression_untyped->clone();

IdentifierResolveScope lambda_scope(lambda_expression_clone, &scope /*parent_scope*/);
Expand Down Expand Up @@ -5018,12 +5012,9 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
}

FunctionOverloadResolverPtr function = UserDefinedExecutableFunctionFactory::instance().tryGet(function_name, scope.context, parameters);
bool is_executable_udf = false;

if (!function)
function = FunctionFactory::instance().tryGet(function_name, scope.context);
else
is_executable_udf = true;

if (!function)
{
Expand Down Expand Up @@ -5074,12 +5065,6 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
return result_projection_names;
}

/// Executable UDFs may have parameters. They are checked in UserDefinedExecutableFunctionFactory.
if (!parameters.empty() && !is_executable_udf)
{
throw Exception(ErrorCodes::FUNCTION_CANNOT_HAVE_PARAMETERS, "Function {} is not parametric", function_name);
}

/** For lambda arguments we need to initialize lambda argument types DataTypeFunction using `getLambdaArgumentTypes` function.
* Then each lambda arguments are initialized with columns, where column source is lambda.
* This information is important for later steps of query processing.
Expand Down
7 changes: 0 additions & 7 deletions src/Functions/UserDefined/UserDefinedSQLFunctionVisitor.cpp
Expand Up @@ -20,7 +20,6 @@ namespace DB
namespace ErrorCodes
{
extern const int UNSUPPORTED_METHOD;
extern const int FUNCTION_CANNOT_HAVE_PARAMETERS;
}

void UserDefinedSQLFunctionVisitor::visit(ASTPtr & ast)
Expand Down Expand Up @@ -139,12 +138,6 @@ ASTPtr UserDefinedSQLFunctionVisitor::tryToReplaceFunction(const ASTFunction & f
if (!user_defined_function)
return nullptr;

/// All UDFs are not parametric for now.
if (function.parameters)
{
throw Exception(ErrorCodes::FUNCTION_CANNOT_HAVE_PARAMETERS, "Function {} is not parametric", function.name);
}

const auto & function_arguments_list = function.children.at(0)->as<ASTExpressionList>();
auto & function_arguments = function_arguments_list->children;

Expand Down
7 changes: 0 additions & 7 deletions src/Interpreters/ActionsVisitor.cpp
Expand Up @@ -78,7 +78,6 @@ namespace ErrorCodes
extern const int LOGICAL_ERROR;
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
extern const int TOO_MANY_ARGUMENTS_FOR_FUNCTION;
extern const int FUNCTION_CANNOT_HAVE_PARAMETERS;
}

static NamesAndTypesList::iterator findColumn(const String & name, NamesAndTypesList & cols)
Expand Down Expand Up @@ -1106,12 +1105,6 @@ void ActionsMatcher::visit(const ASTFunction & node, const ASTPtr & ast, Data &
}
}

/// Normal functions are not parametric for now.
if (node.parameters)
{
throw Exception(ErrorCodes::FUNCTION_CANNOT_HAVE_PARAMETERS, "Function {} is not parametric", node.name);
}

Names argument_names;
DataTypes argument_types;
bool arguments_present = true;
Expand Down
1 change: 1 addition & 0 deletions tests/analyzer_tech_debt.txt
Expand Up @@ -111,6 +111,7 @@
00917_multiple_joins_denny_crane
00725_join_on_bug_1
00636_partition_key_parts_pruning
00261_storage_aliases_and_array_join
01825_type_json_multiple_files
01281_group_by_limit_memory_tracking
02723_zookeeper_name
Expand Down
Empty file.
9 changes: 0 additions & 9 deletions tests/queries/0_stateless/02701_non_parametric_function.sql

This file was deleted.