You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "huangpengtao00-dotcom (via GitHub)" <gi...@apache.org> on 2026/10/13 14:00:29 UTC

Re: [PR] [SPARK-60072][SQL] Expand star arguments in pivot aggregates [spark]

huangpengtao00-dotcom commented on code in PR #59293:
URL: https://github.com/apache/spark/pull/59293#discussion_r4259590650


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -1782,6 +1782,10 @@ class Analyzer(
           }
           expanded
         }
+      // If the pivot aggregate function argument contains Stars, expand it, e.g. count(*) to
+      // count(1), as for Aggregate.
+      case p: Pivot if containsStar(p.aggregates) =>

Review Comment:
   Thanks. Fixed in 2470ff72: a bare top-level star in the pivot aggregates is now rejected up front with `invalidStarUsageError("Pivot", ...)`, wrapped in `withPosition` so the SQL error still points at the star, and only nested stars go through `expandStarExpression`. Added the negative analyzer test you suggested; without the rejection it fails with `UNRESOLVED_COLUMN.WITH_SUGGESTION`. I also updated the description to cover `count(DISTINCT *)` and `max(struct(*))`, which I checked fail before this PR in both DataFrame pivots and SQL `PIVOT`.



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