morrySnow commented on code in PR #65100:
URL: https://github.com/apache/doris/pull/65100#discussion_r3510412131


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java:
##########
@@ -771,13 +771,13 @@ 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 {
                 FunctionUtil.translateToNereidsThrows(this.getFullName(), 
function);
             } catch (Exception e) {
-                name2Function.remove(function.getFunctionName().getFunction());
+                FunctionUtil.removeFunctionImpl(function, name2Function);
                 throw e;
             }
+            Env.getCurrentEnv().getEditLog().logAddFunction(function);

Review Comment:
   Fixed in commit 1f0565f52c384fbd0bafe5227ad6771e05de30bc. Implementation: 
local CREATE TABLES FUNCTION now calls Database.addTableFunction(), which 
builds the <name>_outer companion and sends both functions through one 
addFunctions batch. The batch registers catalog entries and translates all 
added functions to Nereids before writing any logAddFunction edit logs. If the 
companion add conflicts or companion Nereids translation fails, the catch path 
drops any Nereids entries for the batch and removes all functions newly added 
by the batch, so the base UDTF is not visible or durable after the error. Added 
CreateFunctionTest coverage for both _outer translation failure and existing 
_outer overload conflict. I also attempted ./run-fe-ut.sh --run 
org.apache.doris.catalog.CreateFunctionTest#testCreateTableFunctionRollbackWhenOuterFunctionFails,
 but the local workspace failed in fe-core compile before test execution due to 
existing generated parser/annotation errors: missing DorisParser s
 tream/default contexts and SuppressFBWarnings.



-- 
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]

Reply via email to