[SPARK-55155] Fix SET CATALOG to use special chars and backticks in the identifier name #54076
+28
−2
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 changes were proposed in this pull request?
This PR fixes the handling of catalog names with special characters in the
SET CATALOGcommand. The changes modifyResolveSetCatalogCommandto properly wrap identifier parts with backticks and escape any existing backticks by doubling them when convertingSET CATALOGcommands to string literals.Why are the changes needed?
A previous change in #53941 extended the
SET CATALOGcommand to accept foldable expressions. As part of that change, identifiers quoted with backticks are resolved toLiteral("some-identifier")with the backticks stripped. This behavior breaksSET CATALOGwhen catalog names contain special characters such as %, @, -, $, #, or backticks.This fix wraps identifiers in explicit backticks and escapes any existing backticks, ensuring the catalog names are resolved correctly during analysis.
Does this PR introduce any user-facing change?
Yes. Users can continue using
SET CATALOGwith catalog names that contain special characters when properly quoted with backticks:How was this patch tested?
DataSourceV2SQLSuite:
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Sonnet 4.5 - claude-sonnet-4-5-20250929)