[fix](restore) Preserve cross-database references when restoring views#59580
Merged
w41ter merged 1 commit intoapache:masterfrom Jan 8, 2026
Merged
[fix](restore) Preserve cross-database references when restoring views#59580w41ter merged 1 commit intoapache:masterfrom
w41ter merged 1 commit intoapache:masterfrom
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
TPC-H: Total hot run time: 31586 ms |
TPC-DS: Total hot run time: 172546 ms |
ClickBench: Total hot run time: 26.75 s |
861cb61 to
be265ab
Compare
Contributor
Author
|
run buildall |
TPC-H: Total hot run time: 31547 ms |
TPC-DS: Total hot run time: 172214 ms |
ClickBench: Total hot run time: 26.81 s |
be265ab to
9dcd686
Compare
Contributor
Author
|
run buildall |
TPC-H: Total hot run time: 31692 ms |
TPC-DS: Total hot run time: 172754 ms |
ClickBench: Total hot run time: 26.78 s |
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
Author
|
run p0 |
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
|
PR approved by at least one committer and no changes requested. |
Contributor
|
PR approved by anyone and no changes requested. |
w41ter
approved these changes
Jan 8, 2026
github-actions bot
pushed a commit
that referenced
this pull request
Jan 8, 2026
#59580) When restoring a view to a different database, the current implementation incorrectly replaces **all** database names in the view definition with the target database name. This breaks cross-database references. **Example:** - Original: `view_db` has a view referencing tables from both `base_db` and `view_db` ```sql SELECT * FROM `internal`.`base_db`.`table1` JOIN `internal`.`view_db`.`table2` ``` - After restore to `restore_db` (BEFORE this PR): ```sql SELECT * FROM `internal`.`restore_db`.`table1` -- ❌ Wrong! Should be base_db JOIN `internal`.`restore_db`.`table2` -- ✅ Correct ``` - After restore to `restore_db` (AFTER this PR): ```sql SELECT * FROM `internal`.`base_db`.`table1` -- ✅ Correct! Preserved JOIN `internal`.`restore_db`.`table2` -- ✅ Correct ``` **Root Cause:** The regex pattern `(?<=\`internal\`\\.\`)([^\`]+)(?=\`\\.\`)` matches **any** database name, not just the source database name.
Open
16 tasks
zzzxl1993
pushed a commit
to zzzxl1993/doris
that referenced
this pull request
Jan 13, 2026
apache#59580) When restoring a view to a different database, the current implementation incorrectly replaces **all** database names in the view definition with the target database name. This breaks cross-database references. **Example:** - Original: `view_db` has a view referencing tables from both `base_db` and `view_db` ```sql SELECT * FROM `internal`.`base_db`.`table1` JOIN `internal`.`view_db`.`table2` ``` - After restore to `restore_db` (BEFORE this PR): ```sql SELECT * FROM `internal`.`restore_db`.`table1` -- ❌ Wrong! Should be base_db JOIN `internal`.`restore_db`.`table2` -- ✅ Correct ``` - After restore to `restore_db` (AFTER this PR): ```sql SELECT * FROM `internal`.`base_db`.`table1` -- ✅ Correct! Preserved JOIN `internal`.`restore_db`.`table2` -- ✅ Correct ``` **Root Cause:** The regex pattern `(?<=\`internal\`\\.\`)([^\`]+)(?=\`\\.\`)` matches **any** database name, not just the source database name.
16 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
When restoring a view to a different database, the current implementation incorrectly replaces all database names in the view definition with the target database name. This breaks cross-database references.
Example:
view_dbhas a view referencing tables from bothbase_dbandview_dbrestore_db(BEFORE this PR):restore_db(AFTER this PR):Root Cause:
The regex pattern
(?<=\internal`\.`)([^\`]+)(?=`\.`)` matches any database name, not just the source database name.Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)