This is an automated email from the ASF dual-hosted git repository.
dataroaring 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 3412a022f41 [fix](restore) fix Restore from __keep_on_local__ throws
null pointer… (#26943)
3412a022f41 is described below
commit 3412a022f41a2df16666a9fad512a14041f439b1
Author: yuxuan-luo <[email protected]>
AuthorDate: Tue Dec 5 10:55:28 2023 +0800
[fix](restore) fix Restore from __keep_on_local__ throws null pointer…
(#26943)
Co-authored-by: walter <[email protected]>
Co-authored-by: hugoluo <[email protected]>
Co-authored-by: walter <[email protected]>
---
.../org/apache/doris/analysis/RestoreStmt.java | 4 ++
.../test_backup_restore_keep_on_local.groovy | 78 ++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/RestoreStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/RestoreStmt.java
index 3b5f46a37c5..9f5f6ee7253 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/RestoreStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/RestoreStmt.java
@@ -112,6 +112,10 @@ public class RestoreStmt extends AbstractBackupStmt {
public void analyze(Analyzer analyzer) throws UserException {
if (repoName.equals(Repository.KEEP_ON_LOCAL_REPO_NAME)) {
isLocal = true;
+ if (jobInfo == null) {
+ ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
+ "restore from the local repo via SQL call is not
supported");
+ }
}
super.analyze(analyzer);
}
diff --git
a/regression-test/suites/backup_restore/test_backup_restore_keep_on_local.groovy
b/regression-test/suites/backup_restore/test_backup_restore_keep_on_local.groovy
new file mode 100644
index 00000000000..d18006c101c
--- /dev/null
+++
b/regression-test/suites/backup_restore/test_backup_restore_keep_on_local.groovy
@@ -0,0 +1,78 @@
+// 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_backup_restore_keep_on_local", "backup_restore") {
+ String repoName = "__keep_on_local__"
+ String dbName = "backup_restore_keep_on_local_db"
+ String tableName = "test_backup_restore_table"
+
+ def syncer = getSyncer()
+
+ sql "CREATE DATABASE IF NOT EXISTS ${dbName}"
+ sql "DROP TABLE IF EXISTS ${dbName}.${tableName}"
+ sql """
+ CREATE TABLE ${dbName}.${tableName} (
+ `id` LARGEINT NOT NULL,
+ `count` LARGEINT SUM DEFAULT "0")
+ AGGREGATE KEY(`id`)
+ DISTRIBUTED BY HASH(`id`) BUCKETS 2
+ PROPERTIES
+ (
+ "replication_num" = "1"
+ )
+ """
+
+ List<String> values = []
+ for (int i = 1; i <= 10; ++i) {
+ values.add("(${i}, ${i})")
+ }
+ sql "INSERT INTO ${dbName}.${tableName} VALUES ${values.join(",")}"
+ def result = sql "SELECT * FROM ${dbName}.${tableName}"
+ assertEquals(result.size(), values.size());
+
+ String snapshotName = "test_backup_restore_snapshot"
+ sql """
+ BACKUP SNAPSHOT ${dbName}.${snapshotName}
+ TO `${repoName}`
+ ON (${tableName})
+ """
+
+ while (!syncer.checkSnapshotFinish(dbName)) {
+ Thread.sleep(3000)
+ }
+
+ sql "TRUNCATE TABLE ${dbName}.${tableName}"
+
+ try {
+ sql """
+ RESTORE SNAPSHOT ${dbName}.${snapshotName}
+ FROM `${repoName}`
+ ON ( `${tableName}`)
+ PROPERTIES
+ (
+ "replication_num" = "1"
+ )
+ """
+ } catch (Exception e) {
+ // Check the error message
+ assertTrue(e.message.contains("not supported"))
+ }
+
+ sql "DROP TABLE ${dbName}.${tableName} FORCE"
+ sql "DROP DATABASE ${dbName} FORCE"
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]