-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](restore) Preserve cross-database references when restoring views #59580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
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
|
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
|
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 |
FE Regression Coverage ReportIncrement line coverage |
|
run p0 |
FE Regression Coverage ReportIncrement line coverage |
dataroaring
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
#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.
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)