You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "dtenedor (via GitHub)" <gi...@apache.org> on 2026/02/03 18:40:18 UTC

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

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