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