cloud-fan commented on code in PR #52765:
URL: https://github.com/apache/spark/pull/52765#discussion_r2500522183


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -118,6 +118,47 @@ class AstBuilder extends DataTypeAstBuilder
     }
   }
 
+  /**
+   * Override the base getIdentifierParts to properly parse qualified 
identifiers in
+   * IDENTIFIER('literal') contexts. Uses CatalystSqlParser to handle 
qualified identifiers
+   * like IDENTIFIER('`catalog`.`schema`') which should be parsed as 
Seq("catalog", "schema").
+   */
+  override protected def getIdentifierParts(ctx: ParserRuleContext): 
Seq[String] = {
+    ctx match {
+      case idCtx: IdentifierContext =>
+        // identifier can be either strictIdentifier or strictNonReserved
+        // Recursively process the strictIdentifier
+        if (idCtx.strictIdentifier() != null) {
+          getIdentifierParts(idCtx.strictIdentifier())
+        } else {
+          Seq(ctx.getText)
+        }
+      case idLitCtx: IdentifierLiteralContext =>
+        // For IDENTIFIER('literal') in strictIdentifier
+        val literalValue = string(visitStringLit(idLitCtx.stringLit()))
+        // Parse the string as a multi-part identifier
+        // (e.g., "`cat`.`schema`" -> Seq("cat", "schema"))
+        CatalystSqlParser.parseMultipartIdentifier(literalValue)

Review Comment:
   I think `DataTypeAstBuilder` can simply implement 
`parseMultipartIdentifier`? Then we don't need this override here.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to