Gabriel39 commented on code in PR #67695:
URL: https://github.com/apache/doris/pull/67695#discussion_r3966563482


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteActionCommand.java:
##########
@@ -144,6 +144,22 @@ public Optional<Expression> getWhereCondition() {
         return whereCondition;
     }
 
+    private ResultSet executeAuthenticated(ExecuteAction action, ExternalTable 
table) throws Exception {
+        try {
+            // Iceberg tables retain filesystem configuration, not the 
caller's UGI, so table loading and
+            // metadata commits must stay within one catalog authentication 
scope.
+            return table.getCatalog().getExecutionAuthenticator().execute(() 
-> {

Review Comment:
   Fixed in 0d26ac61a4. Action construction now captures metadata ops and the 
authenticator atomically under the catalog reset monitor. Writable acquisition 
is fenced by the captured ops, and a generation change before mutation rebuilds 
the action once under the new generation. Commit failures are not retried. The 
deterministic command test switches from authenticator A to B immediately 
before acquisition and verifies that A never loads or commits.



##########
fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ExecuteActionCommandTest.java:
##########
@@ -0,0 +1,112 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.plans.commands;
+
+import org.apache.doris.catalog.DatabaseIf;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.security.authentication.ExecutionAuthenticator;
+import org.apache.doris.datasource.CatalogIf;
+import org.apache.doris.datasource.CatalogMgr;
+import org.apache.doris.datasource.iceberg.IcebergExternalCatalog;
+import org.apache.doris.datasource.iceberg.IcebergExternalTable;
+import org.apache.doris.info.TableNameInfo;
+import org.apache.doris.nereids.trees.plans.commands.execute.ExecuteAction;
+import 
org.apache.doris.nereids.trees.plans.commands.execute.ExecuteActionFactory;
+import org.apache.doris.persist.EditLog;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+
+import java.util.Collections;
+import java.util.Optional;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+class ExecuteActionCommandTest {
+
+    @Test
+    void executesActionWithinCatalogAuthenticationScope() throws Exception {
+        Env env = Mockito.mock(Env.class);
+        CatalogMgr catalogMgr = Mockito.mock(CatalogMgr.class);
+        CatalogIf<?> catalog = Mockito.mock(CatalogIf.class);
+        DatabaseIf<?> database = Mockito.mock(DatabaseIf.class);
+        IcebergExternalCatalog externalCatalog = 
Mockito.mock(IcebergExternalCatalog.class);
+        IcebergExternalTable table = Mockito.mock(IcebergExternalTable.class);
+        ExecuteAction action = Mockito.mock(ExecuteAction.class);
+        TableNameInfo tableName = Mockito.mock(TableNameInfo.class);
+        ConnectContext context = Mockito.mock(ConnectContext.class);
+        StmtExecutor executor = Mockito.mock(StmtExecutor.class);
+        EditLog editLog = Mockito.mock(EditLog.class);
+        RecordingAuthenticator authenticator = new RecordingAuthenticator();
+        AtomicBoolean actionExecutedInScope = new AtomicBoolean();
+
+        Mockito.when(env.getCatalogMgr()).thenReturn(catalogMgr);
+        Mockito.when(env.getEditLog()).thenReturn(editLog);
+        Mockito.when(tableName.getCtl()).thenReturn("iceberg");
+        Mockito.when(tableName.getDb()).thenReturn("db");
+        Mockito.when(tableName.getTbl()).thenReturn("tbl");
+        Mockito.when(catalogMgr.getCatalog("iceberg")).thenReturn(catalog);
+        Mockito.when(catalog.getDbNullable("db")).thenReturn(database);

Review Comment:
   Fixed in 078b21f5ec. Both wildcard CatalogIf/DatabaseIf lookup chains now 
use doReturn(...).when(...) stubs. The command tests compile and pass locally.



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