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


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergTransaction.java:
##########
@@ -709,20 +726,33 @@ public void commit() throws UserException {
      */
     @VisibleForTesting
     org.apache.iceberg.Transaction newWriteTransaction() {
-        if (!writeSchemaContext.isPresent()) {
-            return table.newTransaction();
-        }
-        Preconditions.checkState(table instanceof HasTableOperations,
-                "Iceberg write table %s does not expose table operations", 
table.name());
-        TableOperations operations = ((HasTableOperations) table).operations();
-        BooleanSupplier requireCurrentPartitionSpec =
-                () -> insertCtx != null && insertCtx.isOverwrite();
-        Table validatingTable = new BaseTable(
-                new ValidatingTableOperations(
-                        operations, writeSchemaContext.get(), 
requireCurrentPartitionSpec,
-                        table.name()),
-                table.name());
-        return validatingTable.newTransaction();
+        return newWriteTransaction(table);
+    }
+
+    private org.apache.iceberg.Transaction newWriteTransaction(Table 
writeTable) {
+        if (!(writeTable instanceof HasTableOperations)) {
+            Preconditions.checkState(!writeSchemaContext.isPresent(),
+                    "Iceberg write table %s does not expose table operations", 
writeTable.name());
+            return writeTable.newTransaction();
+        }
+        TableOperations operations = ((HasTableOperations) 
writeTable).operations();
+        FileIO fileIO = operations.io();
+        if (fileIO instanceof HadoopFileIO) {

Review Comment:
   Fixed in 21b09d934a82. The adapter now activates only for the exact stock 
HadoopFileIO class with a non-no-op authenticator. Configured subclasses retain 
their descriptor-read and bulk-delete overrides. Two SDK-backed tests exercise 
real typed manifest reads and custom bulk deletion; both reproduced the 
previous failure and now pass. A separate test verifies the actual default 
authenticator reuses the original manifest cache.



##########
regression-test/suites/external_table_p0/kerberos/test_iceberg_hadoop_catalog_kerberos.groovy:
##########
@@ -20,6 +20,7 @@ suite("test_iceberg_hadoop_catalog_kerberos", 
"p0,external,kerberos,external_doc
     if (enabled == null || !enabled.equalsIgnoreCase("true")) {
         return
     }
+    // Exercise SDK HadoopFileIO so asynchronous manifest writes must carry 
catalog authentication.

Review Comment:
   Fixed in 21b09d934a82. Restored DelegateFileIO for this existing fixture, 
whose snapshot-expiration cleanup runs outside the write-transaction adapter. 
Stock HadoopFileIO write coverage remains in the isolated HMS manifest suite. 
This keeps the maintenance fixture's original behavior while testing the 
intended write boundary separately.



##########
regression-test/suites/external_table_p0/kerberos/test_iceberg_hms_manifest_kerberos.groovy:
##########
@@ -0,0 +1,127 @@
+// 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.
+
+suite("test_iceberg_hms_manifest_kerberos", 
"p0,external,kerberos,external_docker,external_docker_kerberos") {
+    if 
(!"true".equalsIgnoreCase(context.config.otherConfigs.get("enableKerberosTest")))
 {
+        return
+    }
+    String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+    String suffix = UUID.randomUUID().toString().replace("-", "").substring(0, 
12)
+    String database = "manifest_auth_${suffix}"
+    def fixtures = [
+        [catalog: "iceberg_manifest_a_${suffix}", realm: "LABS.TERADATA.COM", 
host: "hadoop-master",
+         hmsPort: 9583, hdfsPort: 8520, keytab: "hive-presto-master.keytab"],
+        [catalog: "iceberg_manifest_b_${suffix}", realm: "OTHERREALM.COM", 
host: "hadoop-master-2",
+         hmsPort: 9683, hdfsPort: 8620, keytab: 
"other-hive-presto-master.keytab"]
+    ]
+    String rules = 'RULE:[2:$1@$0](.*@LABS.TERADATA.COM)s/@.*//\n' +
+            'RULE:[2:$1@$0](.*@OTHERREALM.COM)s/@.*//\nDEFAULT'
+    def overwriteModeRows = sql "SHOW VARIABLES LIKE 
'iceberg_partition_overwrite_mode'"
+    String previousOverwriteMode = overwriteModeRows.isEmpty() ? null : 
overwriteModeRows[0][1].toString()
+    Throwable failure = null
+    try {
+        if (previousOverwriteMode != null) {
+            sql "SET iceberg_partition_overwrite_mode = 'dynamic'"
+        }
+        fixtures.each { fixture ->
+            // Keep the SDK HadoopFileIO: DelegateFileIO would mask a 
manifest-worker authentication regression.
+            sql """
+                CREATE CATALOG `${fixture.catalog}` PROPERTIES (
+                    "type" = "iceberg",
+                    "iceberg.catalog.type" = "hms",
+                    "warehouse" = 
"hdfs://${externalEnvIp}:${fixture.hdfsPort}/tmp/iceberg/${database}",
+                    "hive.metastore.uris" = 
"thrift://${externalEnvIp}:${fixture.hmsPort}",
+                    "hive.metastore.sasl.enabled" = "true",
+                    "hive.metastore.kerberos.principal" = 
"hive/${fixture.host}@${fixture.realm}",
+                    "fs.defaultFS" = 
"hdfs://${externalEnvIp}:${fixture.hdfsPort}",
+                    "hadoop.security.authentication" = "kerberos",
+                    "hadoop.kerberos.principal" = 
"hive/presto-master.docker.cluster@${fixture.realm}",
+                    "hadoop.kerberos.keytab" = "/keytabs/${fixture.keytab}",
+                    "hadoop.security.auth_to_local" = "${rules}",
+                    "dfs.namenode.kerberos.principal" = 
"hdfs/${fixture.host}@${fixture.realm}",
+                    "dfs.client.use.datanode.hostname" = "true",
+                    "hadoop.security.token.service.use_ip" = "false",
+                    "dfs.data.transfer.protection" = "authentication",
+                    "meta.cache.iceberg.manifest.enable" = "true"
+                )
+            """
+            sql "CREATE DATABASE `${fixture.catalog}`.`${database}`"
+            sql """
+                CREATE TABLE `${fixture.catalog}`.`${database}`.events (id 
INT, payload STRING)
+                ENGINE = iceberg PROPERTIES ("write-format" = "parquet")
+            """
+        }
+        def tableName = { fixture -> 
"`${fixture.catalog}`.`${database}`.events" }
+        def checkRows = { fixture, expected ->
+            sql "REFRESH TABLE ${tableName(fixture)}"
+            def rows = sql "SELECT id, payload FROM ${tableName(fixture)} 
ORDER BY id"
+            assertEquals(expected, rows.collect { row -> row.collect { value 
-> value.toString() } })
+        }
+        // Alternate realms on the same FE so a shared SDK worker must not 
retain the previous catalog's identity.
+        fixtures.each { fixture -> sql "INSERT INTO ${tableName(fixture)} 
VALUES (1, 'first')" }
+        fixtures.reverseEach { fixture -> sql "INSERT INTO 
${tableName(fixture)} VALUES (2, 'second')" }
+        fixtures.each { fixture -> checkRows(fixture, [["1", "first"], ["2", 
"second"]]) }
+        fixtures.each { fixture ->
+            sql "INSERT OVERWRITE TABLE ${tableName(fixture)} SELECT 3, 
'replacement'"
+            checkRows(fixture, [["3", "replacement"]])
+            def snapshots = sql "SELECT count(*) FROM 
`${fixture.catalog}`.`${database}`.`events\$snapshots`"
+            assertEquals(3L, snapshots[0][0] as long)
+            assertFalse((sql "SELECT * FROM 
`${fixture.catalog}`.`${database}`.`events\$history`").isEmpty())
+            assertFalse((sql "SELECT * FROM 
`${fixture.catalog}`.`${database}`.`events\$manifests`").isEmpty())
+            sql "INSERT OVERWRITE TABLE ${tableName(fixture)} SELECT 4, 
'empty' WHERE 1 = 0"

Review Comment:
   Fixed in 21b09d934a82. Both zero-row overwrites now read from a separate, 
never-populated Iceberg table, retaining an external scan that returns zero 
rows at runtime. The assertions require a nonempty destination to become empty, 
and the final REFRESH immediately before the second empty overwrite keeps its 
multi-manifest pre-scan cold. This avoids the older branch's direct-empty 
planner/executor shortcut.



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