zahed1994 commented on PR #59460:
URL: https://github.com/apache/spark/pull/59460#issuecomment-6820103162

   Thanks for the thorough review and guidance, @cloud-fan!
   
   Addressed all findings in commit fc0d8568769:
   
   1. **Planner Sanity Check Unwrapping (P2)**: In 
\SparkStrategies.Aggregation\, updated \distinctAggChildSets\ to unwrap 
\SortOrder\ before filtering foldable expressions (\latMap { case s: SortOrder 
=> s.children; case e => Seq(e) }.filterNot(_.foldable)\), ensuring grouped 
constant-key queries (e.g. \count(DISTINCT 'a')\ with \listagg(DISTINCT 'a', 
',') WITHIN GROUP (ORDER BY 'a')\) align and plan cleanly without internal 
error.
   2. **Document \mustRewrite\ Foldability (P2)**: Retained \evalChildren\ 
foldability check in \RewriteDistinctAggregates.mustRewrite\ and added an 
explanatory comment detailing why constant-only \WITHIN GROUP\ ordering counts 
as all-foldable, why the rule does not rely on planner \SortOrder\ key 
extraction, and why the extra \Expand\ cost is accepted for correct empty-table 
results.
   3. **Test Coverage**:
      - Added grouped constant-key queries testing both argument orderings, 
unordered next to ordered, and subquery literal projections.
      - Added global constant-only ordered \LISTAGG\ tests on both empty input 
(returning \NULL\ alone and with \sum(v)\) and non-empty input (returning \'x'\ 
alone and with \sum(v)\).
   4. **Test Comment & PR Description (P3)**:
      - Updated the comment in \DataFrameAggregateSuite\ to clarify \listagg\ 
is ordered by \i\ itself and aggregates \CAST(i AS STRING)\ (numeric vs 
lexicographic).
      - Updated the PR description to mention the \SparkStrategies.Aggregation\ 
sanity check alignment.
   
   All unit and end-to-end tests (\RewriteDistinctAggregatesSuite\ 38/38, 
\DataFrameAggregateSuite\ 5/5) and scalastyle pass cleanly with 0 errors / 0 
warnings.


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