This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new bfafec47d40 branch-3.0: [fix](view)fix reset view def for restore
wrong replace #50567 (#50599)
bfafec47d40 is described below
commit bfafec47d40330e72ed43c3f29db1d240271b108
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed May 7 10:15:54 2025 +0800
branch-3.0: [fix](view)fix reset view def for restore wrong replace #50567
(#50599)
Cherry-picked from #50567
Co-authored-by: koarz <[email protected]>
---
fe/fe-core/src/main/java/org/apache/doris/catalog/View.java | 3 ++-
.../src/test/java/org/apache/doris/catalog/CreateViewTest.java | 10 ++++++++++
.../suites/backup_restore/test_backup_restore_with_view.groovy | 2 ++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/View.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/View.java
index 69f8b5ebeca..96b0fdf290d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/View.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/View.java
@@ -269,7 +269,8 @@ public class View extends Table implements
GsonPostProcessable {
public void resetViewDefForRestore(String srcDbName, String dbName) {
// the source db name is not setted in old BackupMeta, keep compatible
with the old one.
if (srcDbName != null) {
- inlineViewDef = inlineViewDef.replaceAll(srcDbName, dbName);
+ // replace dbName with a regular expression
+ inlineViewDef =
inlineViewDef.replaceAll("(?<=`internal`\\.`)([^`]+)(?=`\\.`)", dbName);
}
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateViewTest.java
b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateViewTest.java
index 46bf3ddcde9..01c8a4f0ab9 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateViewTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateViewTest.java
@@ -190,4 +190,14 @@ public class CreateViewTest {
+ "ORDER BY `w1` ASC NULLS FIRST",
alter1.getInlineViewDef());
}
+
+ @Test
+ public void testResetViewDefForRestore() {
+ View view = new View();
+ view.setInlineViewDefWithSqlMode("SELECT `internal`.`test`.`test`.`k2`
AS `k1`, "
+ + "FROM `internal`.`test`.`test`;", 1);
+ view.resetViewDefForRestore("test", "test1");
+ Assert.assertEquals("SELECT `internal`.`test1`.`test`.`k2` AS `k1`, "
+ + "FROM `internal`.`test1`.`test`;", view.getInlineViewDef());
+ }
}
diff --git
a/regression-test/suites/backup_restore/test_backup_restore_with_view.groovy
b/regression-test/suites/backup_restore/test_backup_restore_with_view.groovy
index d46791dff05..91328355eca 100644
--- a/regression-test/suites/backup_restore/test_backup_restore_with_view.groovy
+++ b/regression-test/suites/backup_restore/test_backup_restore_with_view.groovy
@@ -125,6 +125,8 @@ suite("test_backup_restore_with_view", "backup_restore") {
restore_result.last()
logger.info("show restore result: ${restore_result}")
assertTrue(restore_result.last().State == "FINISHED")
+ def res = sql "SHOW VIEW FROM ${dbName1}.${tableName}"
+ assertTrue(res.size() > 0)
sql "DROP TABLE ${dbName}.${tableName} FORCE"
sql "DROP VIEW ${dbName}.${viewName}"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]