fix: enrichQueryWithOnCluster misses ON CLUSTER for views with UUID/column-defs#1422
Open
wangyelei wants to merge 1 commit into
Open
fix: enrichQueryWithOnCluster misses ON CLUSTER for views with UUID/column-defs#1422wangyelei wants to merge 1 commit into
wangyelei wants to merge 1 commit into
Conversation
…olumn-defs
The existing regex patterns used [^(]+ in the first capture group, which
stops at '(' from column definitions or UUID, preventing AS SELECT/AS WITH
matching. Changed createViewRe and attachViewRe to use .+? so that UUID
and parenthesized column definitions between the view name and the AS clause
are skipped during match, allowing ON CLUSTER injection to succeed.
Fixes ATTACH LIVE VIEW, ATTACH WINDOW VIEW, and any other view types whose
SHOW CREATE output includes UUID and/or explicit column definitions.
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.
Problem
When
restore_schema_on_clusteris configured and restoring views that haveUUIDand/or explicit column definitions (e.g.LIVE VIEW,WINDOW VIEW), theenrichQueryWithOnCluster()function fails to injectON CLUSTERinto the restored DDL.Root cause
The regex patterns
createViewReandattachViewReused[^(]+in the first capture group. This stops at the first(character, which in queries like:prevents the regex from ever reaching the
AS SELECTclause, soON CLUSTERis never injected.Fix
Changed
createViewReandattachViewRefirst capture group from[^(]+to.+?(lazy match), which skips past UUID and parenthesized column definitions to correctly locateAS SELECTfor ON CLUSTER insertion.Reproduce
restore_schema_on_cluster: 'default'Two queries restored without ON CLUSTER:
This results in the views only being created on the current node, causing subsequent data restore to fail:
Other view types (
MATERIALIZED VIEW ... TO,CREATE VIEW,CREATE DICTIONARY,CREATE TABLE) were unaffected because they matched different regex patterns.