github-actions[bot] commented on code in PR #65100:
URL: https://github.com/apache/doris/pull/65100#discussion_r3556195917
##########
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:
This repair path builds the missing `_outer` from the newly submitted
statement, not from the existing base UDTF that is being preserved.
`getExistingFunction()` only proves catalog identity (name/args/varargs); it
does not compare implementation metadata such as object file, symbol, return
type, volatility, checksum, static-load/expiry, or function code. So a
base-only residue from implementation A followed by `CREATE TABLES FUNCTION IF
NOT EXISTS f(INT) ...` for implementation B will keep `f` from A but register
`f_outer` from B, leaving the logical pair inconsistent. Please clone
`existingFunction` for the repair, or reject the repair unless the submitted
definition is proven equivalent to the existing base, and add a test where the
two definitions differ.
--
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]