This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 84d7cbe7fc6 [Enhancement](nereids) cancel convert TableRefInfo to 
TableRef in RestoreCommand (#52564)
84d7cbe7fc6 is described below

commit 84d7cbe7fc6b781c490bdb2f4ed704d862d6e146
Author: yaoxiao <[email protected]>
AuthorDate: Tue Jul 1 15:05:24 2025 +0800

    [Enhancement](nereids) cancel convert TableRefInfo to TableRef in 
RestoreCommand (#52564)
---
 .../org/apache/doris/backup/BackupHandler.java     | 39 +++++++++---
 .../org/apache/doris/backup/BackupJobInfo.java     | 70 ++++++++++++++++++++++
 2 files changed, 100 insertions(+), 9 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java 
b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
index d757f474151..3c6339af1b7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
@@ -56,6 +56,7 @@ import 
org.apache.doris.nereids.trees.plans.commands.BackupCommand;
 import org.apache.doris.nereids.trees.plans.commands.CancelBackupCommand;
 import org.apache.doris.nereids.trees.plans.commands.CreateRepositoryCommand;
 import org.apache.doris.nereids.trees.plans.commands.RestoreCommand;
+import org.apache.doris.nereids.trees.plans.commands.info.PartitionNamesInfo;
 import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
 import org.apache.doris.nereids.trees.plans.commands.info.TableRefInfo;
 import org.apache.doris.persist.BarrierLog;
@@ -1034,19 +1035,18 @@ public class BackupHandler extends MasterDaemon 
implements Writable {
         // case2: exclude table ref
         if (command.isExclude()) {
             for (TableRefInfo tableRefInfo : command.getTableRefInfos()) {
-                TableRef tableRef = tableRefInfo.translateToLegacyTableRef();
-                String tblName = tableRef.getName().getTbl();
+                String tblName = tableRefInfo.getTableNameInfo().getTbl();
                 TableType tableType = jobInfo.getTypeByTblName(tblName);
                 if (tableType == null) {
                     LOG.info("Ignore error : exclude table " + tblName + " 
does not exist in snapshot "
                             + jobInfo.name);
                     continue;
                 }
-                if (tableRef.hasExplicitAlias()) {
+                if (tableRefInfo.hasAlias()) {
                     ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
                             "The table alias in exclude clause does not make 
sense");
                 }
-                jobInfo.removeTable(tableRef, tableType);
+                jobInfo.removeTable(tableRefInfo, tableType);
             }
             return;
         }
@@ -1056,8 +1056,7 @@ public class BackupHandler extends MasterDaemon 
implements Writable {
         Set<String> viewNames = Sets.newHashSet();
         Set<String> odbcTableNames = Sets.newHashSet();
         for (TableRefInfo tableRefInfo : command.getTableRefInfos()) {
-            TableRef tblRef = tableRefInfo.translateToLegacyTableRef();
-            String tblName = tblRef.getName().getTbl();
+            String tblName = tableRefInfo.getTableNameInfo().getTbl();
             TableType tableType = jobInfo.getTypeByTblName(tblName);
             if (tableType == null) {
                 ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
@@ -1065,7 +1064,7 @@ public class BackupHandler extends MasterDaemon 
implements Writable {
             }
             switch (tableType) {
                 case OLAP:
-                    
checkAndFilterRestoreOlapTableExistInSnapshot(jobInfo.backupOlapTableObjects, 
tblRef);
+                    
checkAndFilterRestoreOlapTableExistInSnapshot(jobInfo.backupOlapTableObjects, 
tableRefInfo);
                     olapTableNames.add(tblName);
                     break;
                 case VIEW:
@@ -1079,8 +1078,8 @@ public class BackupHandler extends MasterDaemon 
implements Writable {
             }
 
             // set alias
-            if (tblRef.hasExplicitAlias()) {
-                jobInfo.setAlias(tblName, tblRef.getExplicitAlias());
+            if (tableRefInfo.hasAlias()) {
+                jobInfo.setAlias(tblName, tableRefInfo.getTableAlias());
             }
         }
         jobInfo.retainOlapTables(olapTableNames);
@@ -1151,6 +1150,28 @@ public class BackupHandler extends MasterDaemon 
implements Writable {
     }
 
 
+    public void checkAndFilterRestoreOlapTableExistInSnapshot(Map<String, 
BackupOlapTableInfo> backupOlapTableInfoMap,
+                                                              TableRefInfo 
tableRefInfo) throws DdlException {
+        String tblName = tableRefInfo.getTableNameInfo().getTbl();
+        BackupOlapTableInfo tblInfo = backupOlapTableInfoMap.get(tblName);
+        PartitionNamesInfo partitionNamesInfo = 
tableRefInfo.getPartitionNamesInfo();
+        if (partitionNamesInfo != null) {
+            if (partitionNamesInfo.isTemp()) {
+                ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
+                        "Do not support restoring temporary partitions in 
table " + tblName);
+            }
+            // check the selected partitions
+            for (String partName : partitionNamesInfo.getPartitionNames()) {
+                if (!tblInfo.containsPart(partName)) {
+                    ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
+                            "Partition " + partName + " of table " + tblName
+                            + " does not exist in snapshot");
+                }
+            }
+        }
+        // only retain restore partitions
+        tblInfo.retainPartitions(partitionNamesInfo == null ? null : 
partitionNamesInfo.getPartitionNames());
+    }
 
     public void checkAndFilterRestoreOlapTableExistInSnapshot(Map<String, 
BackupOlapTableInfo> backupOlapTableInfoMap,
                                                               TableRef 
tableRef) throws DdlException {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJobInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJobInfo.java
index 82cd473b848..5a659febf0b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJobInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJobInfo.java
@@ -35,6 +35,8 @@ import org.apache.doris.catalog.View;
 import org.apache.doris.common.Config;
 import org.apache.doris.common.FeConstants;
 import org.apache.doris.common.Version;
+import org.apache.doris.nereids.trees.plans.commands.info.PartitionNamesInfo;
+import org.apache.doris.nereids.trees.plans.commands.info.TableRefInfo;
 import org.apache.doris.persist.gson.GsonPostProcessable;
 import org.apache.doris.persist.gson.GsonUtils;
 import org.apache.doris.thrift.TNetworkAddress;
@@ -190,6 +192,22 @@ public class BackupJobInfo implements GsonPostProcessable {
         return backupOlapTableObjects.get(tblName);
     }
 
+    public void removeTable(TableRefInfo tableRefInfo, TableType tableType) {
+        switch (tableType) {
+            case OLAP:
+                removeOlapTable(tableRefInfo);
+                break;
+            case VIEW:
+                removeView(tableRefInfo);
+                break;
+            case ODBC:
+                removeOdbcTable(tableRefInfo);
+                break;
+            default:
+                break;
+        }
+    }
+
     public void removeTable(TableRef tableRef, TableType tableType) {
         switch (tableType) {
             case OLAP:
@@ -206,6 +224,58 @@ public class BackupJobInfo implements GsonPostProcessable {
         }
     }
 
+    public void removeOlapTable(TableRefInfo tableRefInfo) {
+        String tblName = tableRefInfo.getTableNameInfo().getTbl();
+        BackupOlapTableInfo tblInfo = backupOlapTableObjects.get(tblName);
+        if (tblInfo == null) {
+            LOG.info("Ignore error: exclude table " + tblName + " does not 
exist in snapshot " + name);
+            return;
+        }
+        PartitionNamesInfo partitionNamesInfo = 
tableRefInfo.getPartitionNamesInfo();
+        if (partitionNamesInfo == null) {
+            backupOlapTableObjects.remove(tblInfo);
+            return;
+        }
+        // check the selected partitions
+        for (String partName : partitionNamesInfo.getPartitionNames()) {
+            if (tblInfo.containsPart(partName)) {
+                tblInfo.partitions.remove(partName);
+            } else {
+                LOG.info("Ignore error: exclude partition " + partName + " of 
table " + tblName
+                        + " does not exist in snapshot");
+            }
+        }
+    }
+
+    public void removeView(TableRefInfo tableRefInfo) {
+        Iterator<BackupViewInfo> iter = newBackupObjects.views.listIterator();
+        while (iter.hasNext()) {
+            if 
(iter.next().name.equals(tableRefInfo.getTableNameInfo().getTbl())) {
+                iter.remove();
+                return;
+            }
+        }
+    }
+
+    public void removeOdbcTable(TableRefInfo tableRefInfo) {
+        Iterator<BackupOdbcTableInfo> iter = 
newBackupObjects.odbcTables.listIterator();
+        while (iter.hasNext()) {
+            BackupOdbcTableInfo backupOdbcTableInfo = iter.next();
+            if 
(backupOdbcTableInfo.dorisTableName.equals(tableRefInfo.getTableNameInfo().getTbl()))
 {
+                if (backupOdbcTableInfo.resourceName != null) {
+                    Iterator<BackupOdbcResourceInfo> resourceIter = 
newBackupObjects.odbcResources.listIterator();
+                    while (resourceIter.hasNext()) {
+                        if 
(resourceIter.next().name.equals(backupOdbcTableInfo.resourceName)) {
+                            resourceIter.remove();
+                        }
+                    }
+                }
+                iter.remove();
+                return;
+            }
+        }
+    }
+
     public void removeOlapTable(TableRef tableRef) {
         String tblName = tableRef.getName().getTbl();
         BackupOlapTableInfo tblInfo = backupOlapTableObjects.get(tblName);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to