This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 85cc442402c branch-3.1: [fix](iceberg)Enforce authentication before
executing branch/tag DDL operations #55320 (#55372)
85cc442402c is described below
commit 85cc442402ce92e7536e1b3e8869d42608c32dca
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Aug 28 09:46:42 2025 +0800
branch-3.1: [fix](iceberg)Enforce authentication before executing
branch/tag DDL operations #55320 (#55372)
Cherry-picked from #55320
Co-authored-by: Calvin Kirs <[email protected]>
---
.../datasource/iceberg/IcebergMetadataOps.java | 73 ++++++++++++++--------
.../IcebergExternalTableBranchAndTagTest.java | 5 +-
2 files changed, 49 insertions(+), 29 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java
index 7db5f4e497d..4818b722fcf 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java
@@ -41,6 +41,7 @@ import
org.apache.doris.nereids.trees.plans.commands.info.DropBranchInfo;
import org.apache.doris.nereids.trees.plans.commands.info.DropTagInfo;
import org.apache.doris.nereids.trees.plans.commands.info.TagOptions;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.iceberg.ManageSnapshots;
import org.apache.iceberg.PartitionSpec;
import org.apache.iceberg.Schema;
@@ -401,18 +402,32 @@ public class IcebergMetadataOps implements
ExternalMetadataOps {
// use current snapshot
Optional.ofNullable(icebergTable.currentSnapshot()).map(Snapshot::snapshotId).orElse(null));
- ManageSnapshots manageSnapshots = icebergTable.manageSnapshots();
+ ManageSnapshots manageSnapshots;
+ try {
+ manageSnapshots =
executionAuthenticator.execute(icebergTable::manageSnapshots);
+ } catch (Exception e) {
+ throw new RuntimeException(
+ "Failed to create ManageSnapshots for table: " +
icebergTable.name()
+ + ", error message is: {} " +
ExceptionUtils.getRootCauseMessage(e), e);
+ }
String branchName = branchInfo.getBranchName();
boolean refExists = null != icebergTable.refs().get(branchName);
boolean create = branchInfo.getCreate();
boolean replace = branchInfo.getReplace();
boolean ifNotExists = branchInfo.getIfNotExists();
-
Runnable safeCreateBranch = () -> {
- if (snapshotId == null) {
- manageSnapshots.createBranch(branchName);
- } else {
- manageSnapshots.createBranch(branchName, snapshotId);
+ try {
+ executionAuthenticator.execute(() -> {
+ if (snapshotId == null) {
+ manageSnapshots.createBranch(branchName);
+ } else {
+ manageSnapshots.createBranch(branchName, snapshotId);
+ }
+ });
+ } catch (Exception e) {
+ throw new RuntimeException(
+ "Failed to create branch: " + branchName + " in table:
" + icebergTable.name()
+ + ", error message is: {} " +
ExceptionUtils.getRootCauseMessage(e), e);
}
};
@@ -438,7 +453,7 @@ public class IcebergMetadataOps implements
ExternalMetadataOps {
branchOptions.getRetention().ifPresent(n ->
manageSnapshots.setMaxRefAgeMs(branchName, n));
try {
- executionAuthenticator.execute(() -> manageSnapshots.commit());
+ executionAuthenticator.execute(manageSnapshots::commit);
} catch (Exception e) {
throw new RuntimeException(
"Failed to create or replace branch: " + branchName + " in
table: " + icebergTable.name()
@@ -481,21 +496,23 @@ public class IcebergMetadataOps implements
ExternalMetadataOps {
boolean ifNotExists = tagInfo.getIfNotExists();
boolean refExists = null != icebergTable.refs().get(tagName);
- ManageSnapshots manageSnapshots = icebergTable.manageSnapshots();
- if (create && replace && !refExists) {
- manageSnapshots.createTag(tagName, snapshotId);
- } else if (replace) {
- manageSnapshots.replaceTag(tagName, snapshotId);
- } else {
- if (refExists && ifNotExists) {
- return;
- }
- manageSnapshots.createTag(tagName, snapshotId);
- }
- tagOptions.getRetain().ifPresent(n ->
manageSnapshots.setMaxRefAgeMs(tagName, n));
try {
- executionAuthenticator.execute(() -> manageSnapshots.commit());
+ executionAuthenticator.execute(() -> {
+ ManageSnapshots manageSnapshots =
icebergTable.manageSnapshots();
+ if (create && replace && !refExists) {
+ manageSnapshots.createTag(tagName, snapshotId);
+ } else if (replace) {
+ manageSnapshots.replaceTag(tagName, snapshotId);
+ } else {
+ if (refExists && ifNotExists) {
+ return;
+ }
+ manageSnapshots.createTag(tagName, snapshotId);
+ }
+ tagOptions.getRetain().ifPresent(n ->
manageSnapshots.setMaxRefAgeMs(tagName, n));
+ manageSnapshots.commit();
+ });
} catch (Exception e) {
throw new RuntimeException(
"Failed to create or replace tag: " + tagName + " in
table: " + icebergTable.name()
@@ -511,13 +528,15 @@ public class IcebergMetadataOps implements
ExternalMetadataOps {
SnapshotRef snapshotRef = icebergTable.refs().get(tagName);
if (snapshotRef != null || !ifExists) {
- ManageSnapshots manageSnapshots = icebergTable.manageSnapshots();
try {
- executionAuthenticator.execute(() ->
manageSnapshots.removeTag(tagName).commit());
+ executionAuthenticator.execute(() -> {
+ ManageSnapshots manageSnapshots =
icebergTable.manageSnapshots();
+ manageSnapshots.removeTag(tagName).commit();
+ });
} catch (Exception e) {
throw new RuntimeException(
"Failed to drop tag: " + tagName + " in table: " +
icebergTable.name()
- + ", error message is: " + e.getMessage(), e);
+ + ", error message is: " + e.getMessage(), e);
}
}
}
@@ -530,13 +549,15 @@ public class IcebergMetadataOps implements
ExternalMetadataOps {
SnapshotRef snapshotRef = icebergTable.refs().get(branchName);
if (snapshotRef != null || !ifExists) {
- ManageSnapshots manageSnapshots = icebergTable.manageSnapshots();
try {
- executionAuthenticator.execute(() ->
manageSnapshots.removeBranch(branchName).commit());
+ executionAuthenticator.execute(() -> {
+ ManageSnapshots manageSnapshots =
icebergTable.manageSnapshots();
+ manageSnapshots.removeBranch(branchName).commit();
+ });
} catch (Exception e) {
throw new RuntimeException(
"Failed to drop branch: " + branchName + " in table: "
+ icebergTable.name()
- + ", error message is: " + e.getMessage(), e);
+ + ", error message is: " + e.getMessage(), e);
}
}
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergExternalTableBranchAndTagTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergExternalTableBranchAndTagTest.java
index 072042683b9..720f66fd5f9 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergExternalTableBranchAndTagTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergExternalTableBranchAndTagTest.java
@@ -159,7 +159,7 @@ public class IcebergExternalTableBranchAndTagTest {
// create an existed tag: tag1
Assertions.assertThrows(
- IllegalArgumentException.class,
+ RuntimeException.class,
() -> catalog.createOrReplaceTag(dorisTable, info));
// create an existed tag with replace
@@ -241,8 +241,7 @@ public class IcebergExternalTableBranchAndTagTest {
true, null, null, null);
// create an existed branch, failed
- Assertions.assertThrows(
- IllegalArgumentException.class,
+ Assertions.assertThrowsExactly(RuntimeException.class,
() -> catalog.createOrReplaceBranch(dorisTable, info));
// create or replace an empty branch, will fail
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]