hello-stephen commented on code in PR #71398:
URL: https://github.com/apache/doris/pull/71398#discussion_r4790158043
##########
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:
[P2] Preserve the behavior of custom HadoopFileIO implementations. A catalog
can configure a HadoopFileIO subclass via `io-impl`, but wrapping it here
replaces its overridden `deleteFiles` with the SDK's per-file loop. Iceberg
transaction cleanup then bypasses the subclass's bulk behavior, even with no-op
authentication. Manifest scans likewise bypass an override of
`newInputFile(ManifestFile)`. Limit the wrapper to the stock implementation or
preserve custom dispatch at both entry points. [Transaction
cleanup](https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/main/java/org/apache/iceberg/BaseTransaction.java#L409-L411),
[bulk
dispatch](https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/main/java/org/apache/iceberg/hadoop/HadoopFileIO.java#L172-L194),
[manifest
reads](https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/main/java/org/apache/iceberg/ManifestFiles.java#L533-L538).
##########
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:
[P2] Make both empty overwrites return zero rows at execution time. In cloud
mode or with `enable_strict_consistency_dml` off, Nereids folds `WHERE 1 = 0`
to a direct `PhysicalEmptyRelation` under the Iceberg sink.
`InsertIntoTableCommand` skips the transaction because only static-partition
overwrites opt into executing that plan. The previous rows remain, so
`checkRows(..., [])` fails without exercising manifest authentication. Use a
data-dependent no-match filter or a real empty source table as in
`test_iceberg_insert_overwrite_with_empty_table.groovy`.
##########
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:
[P2] Keep the rollback and expiration fixture on DelegateFileIO unless the
expiration planner is authenticated too. After rollback and the next append,
`expire_snapshots` uses Iceberg's reachable-file cleanup. It opens manifest
lists on the shared SDK pool with the raw table FileIO, outside the write
transaction wrapper. A worker without this catalog's credentials can make the
SQL fail after snapshot metadata has already committed. A separate HadoopFileIO
write case would cover this fix without changing the existing expiration
fixture. [Expiration and cleanup
selection](https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/main/java/org/apache/iceberg/RemoveSnapshots.java#L324-L372),
[worker
reads](https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/main/java/org/apache/iceberg/ReachableFileCleanup.java#L131-L152).
--
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]