morningman commented on code in PR #56257:
URL: https://github.com/apache/doris/pull/56257#discussion_r2384697337


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/action/IcebergRollbackToTimestampAction.java:
##########
@@ -34,6 +43,7 @@
  * at a specific timestamp.
  */
 public class IcebergRollbackToTimestampAction extends BaseIcebergAction {
+    private static final DateTimeFormatter DATETIME_MS_FORMAT = 
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");

Review Comment:
   must with millionsecond?
   



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/action/IcebergCherrypickSnapshotAction.java:
##########
@@ -65,7 +71,38 @@ protected void validateIcebergAction() throws UserException {
 
     @Override
     protected List<String> executeAction(TableIf table) throws UserException {
-        throw new DdlException("Iceberg cherrypick_snapshot procedure is not 
implemented yet");
+        Table icebergTable = ((IcebergExternalTable) table).getIcebergTable();
+        Long sourceSnapshotId = namedArguments.getLong(SNAPSHOT_ID);
+
+        try {
+            Snapshot targetSnapshot = icebergTable.snapshot(sourceSnapshotId);
+            if (targetSnapshot == null) {
+                throw new UserException("Snapshot not found in table");
+            }
+
+            
icebergTable.manageSnapshots().cherrypick(sourceSnapshotId).commit();
+            Snapshot currentSnapshot = icebergTable.currentSnapshot();
+
+            // invalid iceberg catalog table cache.
+            
Env.getCurrentEnv().getExtMetaCacheMgr().invalidateTableCache((ExternalTable) 
table);
+            return Lists.newArrayList(
+                    String.valueOf(sourceSnapshotId),
+                    String.valueOf(currentSnapshot.snapshotId()
+                    )
+            );
+
+        } catch (Exception e) {
+            throw new UserException("Failed to cherry-pick snapshot " + 
sourceSnapshotId + ": " + e.getMessage(), e);

Review Comment:
   ```suggestion
               throw new UserException("Failed to cherry-pick snapshot " + 
sourceSnapshotId + ": " + Util.getRootCause(e.getMessage()), e);
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/action/IcebergCherrypickSnapshotAction.java:
##########
@@ -65,7 +71,38 @@ protected void validateIcebergAction() throws UserException {
 
     @Override
     protected List<String> executeAction(TableIf table) throws UserException {
-        throw new DdlException("Iceberg cherrypick_snapshot procedure is not 
implemented yet");
+        Table icebergTable = ((IcebergExternalTable) table).getIcebergTable();
+        Long sourceSnapshotId = namedArguments.getLong(SNAPSHOT_ID);
+
+        try {
+            Snapshot targetSnapshot = icebergTable.snapshot(sourceSnapshotId);
+            if (targetSnapshot == null) {
+                throw new UserException("Snapshot not found in table");
+            }
+
+            
icebergTable.manageSnapshots().cherrypick(sourceSnapshotId).commit();
+            Snapshot currentSnapshot = icebergTable.currentSnapshot();
+
+            // invalid iceberg catalog table cache.
+            
Env.getCurrentEnv().getExtMetaCacheMgr().invalidateTableCache((ExternalTable) 
table);
+            return Lists.newArrayList(
+                    String.valueOf(sourceSnapshotId),
+                    String.valueOf(currentSnapshot.snapshotId()
+                    )
+            );
+
+        } catch (Exception e) {
+            throw new UserException("Failed to cherry-pick snapshot " + 
sourceSnapshotId + ": " + e.getMessage(), e);

Review Comment:
   Same for other UserException



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