You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "tangrizzly (via GitHub)" <gi...@apache.org> on 2026/01/30 22:19:24 UTC

[PR] init [spark]

tangrizzly opened a new pull request, #54076:
URL: https://github.com/apache/spark/pull/54076

   ### 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 https://github.com/apache/spark/pull/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 now use `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 (escaped by doubling)
   
   ### 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)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55155] Fix SET CATALOG to use special chars and backticks in the identifier name [spark]

Posted by "dtenedor (via GitHub)" <gi...@apache.org>.
dtenedor commented on PR #54076:
URL: https://github.com/apache/spark/pull/54076#issuecomment-3960802672

   LGTM, merging to master


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55155] Fix SET CATALOG to use special chars and backticks in the identifier name [spark]

Posted by "yuyuant (via GitHub)" <gi...@apache.org>.
yuyuant commented on code in PR #54076:
URL: https://github.com/apache/spark/pull/54076#discussion_r2848830355


##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSetCatalogCommand.scala:
##########
@@ -32,8 +32,13 @@ object ResolveSetCatalogCommand extends Rule[LogicalPlan] {
     case cmd @ SetCatalogCommand(expr) =>
       val resolvedExpr = expr match {
         case UnresolvedAttribute(nameParts) =>
-          // Convert `SET CATALOG foo` into Literal("foo").
-          Literal(nameParts.mkString("."))
+          // Convert `SET CATALOG foo` into Literal("`foo`").
+          // Wrap each identifier part with backticks to handle special characters.
+          // Escape any existing backticks in the identifier name by doubling them.
+          Literal(nameParts.map { part =>
+            val escaped = part.replace("`", "``")

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55155] Fix SET CATALOG to use special chars and backticks in the identifier name [spark]

Posted by "dtenedor (via GitHub)" <gi...@apache.org>.
dtenedor commented on code in PR #54076:
URL: https://github.com/apache/spark/pull/54076#discussion_r2760481032


##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSetCatalogCommand.scala:
##########
@@ -32,8 +32,13 @@ object ResolveSetCatalogCommand extends Rule[LogicalPlan] {
     case cmd @ SetCatalogCommand(expr) =>
       val resolvedExpr = expr match {
         case UnresolvedAttribute(nameParts) =>
-          // Convert `SET CATALOG foo` into Literal("foo").
-          Literal(nameParts.mkString("."))
+          // Convert `SET CATALOG foo` into Literal("`foo`").
+          // Wrap each identifier part with backticks to handle special characters.
+          // Escape any existing backticks in the identifier name by doubling them.
+          Literal(nameParts.map { part =>
+            val escaped = part.replace("`", "``")

Review Comment:
   It looks like similar functionality already exists in QuotingUtils.scala, can we consolidate?
   
   https://github.com/apache/spark/blob/9788c52426df29fe4d145255f7a7f945bee96d3a/sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/QuotingUtils.scala#L36-L40



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55155] Fix SET CATALOG to use special chars and backticks in the identifier name [spark]

Posted by "dtenedor (via GitHub)" <gi...@apache.org>.
dtenedor closed pull request #54076: [SPARK-55155] Fix SET CATALOG to use special chars and backticks in the identifier name
URL: https://github.com/apache/spark/pull/54076


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] init [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #54076:
URL: https://github.com/apache/spark/pull/54076#issuecomment-3826054437

   ## ⚠️ Pull Request Title Validation
   
   This pull request title does not contain a JIRA issue ID.
   
   Please update the title to either:
   - Include a JIRA ID: `[SPARK-12345] Your description`
   - Mark as minor change: `[MINOR] Your description`
   
   For minor changes that don't require a JIRA ticket (e.g., typo fixes), please prefix the title with `[MINOR]`.
   
   ---
   *This comment was automatically generated by GitHub Actions*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org