Skip to content

Conversation

@tangrizzly
Copy link

@tangrizzly tangrizzly commented Jan 30, 2026

What changes were proposed in this pull request?

This PR fixes the handling of catalog names with special characters in the SET CATALOG command. The changes modify ResolveSetCatalogCommand to properly wrap identifier parts with backticks and escape any existing backticks by doubling them when converting SET CATALOG commands to string literals.

Why are the changes needed?

A previous change in #53941 extended the SET CATALOG command to accept foldable expressions. As part of that change, identifiers quoted with backticks are resolved to Literal("some-identifier") with the backticks stripped. This behavior breaks SET CATALOG when 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 CATALOG with catalog names that contain special characters when properly quoted with backticks:

SET CATALOG `te%s@t-c$a#t` -- works with special characters
SET CATALOG ``test`quote` -- works with backticks in the name

How was this patch tested?

DataSourceV2SQLSuite:

  • SET CATALOG with special characters with backticks in identifier
  • SET CATALOG with backtick character in identifier

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Sonnet 4.5 - claude-sonnet-4-5-20250929)

@github-actions
Copy link

github-actions bot commented Jan 30, 2026

JIRA Issue Information

=== Improvement SPARK-55155 ===
Summary: Support foldable expression for SET CATALOG
Assignee: Yuyuan Tang
Status: Resolved
Affected: ["4.2.0","4.1.2"]


This comment was automatically generated by GitHub Actions

@github-actions github-actions bot added the SQL label Jan 30, 2026
@tangrizzly tangrizzly changed the title init [SPARK-55155] Fix SET CATALOG to use special chars and backticks in the identifier name Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants