srielau commented on code in PR #53570:
URL: https://github.com/apache/spark/pull/53570#discussion_r2867579445


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -1823,23 +1823,34 @@ class Analyzer(
       case _ => false
     }
 
+    /**
+     * Checks if the given function name parts match the expected builtin 
function name.
+     * This is used for special syntax transformations (e.g., COUNT(*) -> 
COUNT(1)) that
+     * should only apply to builtin functions, not to user-defined functions.
+     */
+    private def matchesFunctionName(nameParts: Seq[String], expectedName: 
String): Boolean = {
+      FunctionResolution.isUnqualifiedOrBuiltinFunctionName(nameParts, 
expectedName)
+    }
+
     /**
      * Expands the matching attribute.*'s in `child`'s output.
      */
     def expandStarExpression(expr: Expression, child: LogicalPlan): Expression 
= {
       expr.transformUp {
         case f0: UnresolvedFunction if !f0.isDistinct &&
-          f0.nameParts.map(_.toLowerCase(Locale.ROOT)) == Seq("count") &&
+          matchesFunctionName(f0.nameParts, "count") &&
           isCountStarExpansionAllowed(f0.arguments) =>
           // Transform COUNT(*) into COUNT(1).
-          f0.copy(nameParts = Seq("count"), arguments = Seq(Literal(1)))

Review Comment:
   Unclear. I do not know



-- 
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