Skip to content

Commit

Permalink
enhance UDF name validation (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhou1111 authored Jan 17, 2024
1 parent 31bd5b5 commit 3cdf22f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Functions/UserDefined/UDFHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <Functions/UserDefined/UDFHelper.h>

#include <AggregateFunctions/AggregateFunctionCombinatorFactory.h>
#include <DataTypes/DataTypeFactory.h>
#include <Functions/UserDefined/IUserDefinedSQLObjectsLoader.h>
#include <Functions/UserDefined/UserDefinedExecutableFunction.h>
Expand Down Expand Up @@ -51,6 +52,9 @@ void validateUDFName(const String & func_name)

if (!std::isalpha(func_name[0]) && func_name[0] != '_')
throw Exception(ErrorCodes::UDF_INVALID_NAME, "UDF name's first char shall be an alphabetic or underscore");

if (AggregateFunctionCombinatorPtr combinator = AggregateFunctionCombinatorFactory::instance().tryFindSuffix(func_name))
throw Exception(fmt::format("UDF name can not end up with {}, because it is key word suffix", combinator->getName()), ErrorCodes::UDF_INVALID_NAME);
}

namespace
Expand Down

0 comments on commit 3cdf22f

Please sign in to comment.