morrySnow commented on code in PR #65100:
URL: https://github.com/apache/doris/pull/65100#discussion_r3558152736
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java:
##########
@@ -769,18 +769,92 @@ public void setName(String name) {
}
public synchronized void addFunction(Function function, boolean
ifNotExists) throws UserException {
- function.checkWritable();
- if (FunctionUtil.addFunctionImpl(function, ifNotExists, false,
name2Function)) {
- Env.getCurrentEnv().getEditLog().logAddFunction(function);
- try {
+ addFunctions(ImmutableList.of(function), ifNotExists, false);
+ }
+
+ public synchronized void addTableFunction(Function function, boolean
ifNotExists) throws UserException {
+ // Doris table functions are registered as two functions: the normal
function and its outer variant.
+ Function outerFunction = function.clone();
+ FunctionName name = outerFunction.getFunctionName();
+ name.setFn(name.getFunction() + "_outer");
+ List<Function> functionsToAdd = getTableFunctionsToAdd(function,
outerFunction, ifNotExists);
+ if (functionsToAdd.isEmpty()) {
+ return;
+ }
+ addFunctions(functionsToAdd, false, functionsToAdd.size() > 1);
+ }
+
+ private List<Function> getTableFunctionsToAdd(Function function, Function
outerFunction, boolean ifNotExists)
+ throws UserException {
+ Function existingFunction = getExistingFunction(function);
+ Function existingOuterFunction = getExistingFunction(outerFunction);
+ if (existingFunction == null && existingOuterFunction == null) {
+ return ImmutableList.of(function, outerFunction);
+ }
+ // Only a base-only UDTF residue is safe to repair; an outer-only
function may belong to another UDTF.
+ if (!ifNotExists || existingFunction == null ||
!existingFunction.isUDTFunction()
+ || (existingOuterFunction != null &&
!existingOuterFunction.isUDTFunction())) {
+ throw new
UserException(getExistingFunctionMessage(existingFunction,
existingOuterFunction));
+ }
+ if (existingOuterFunction != null) {
+ return ImmutableList.of();
+ }
+ return ImmutableList.of(outerFunction);
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]