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

   Thanks for catching this edge case, @cloud-fan!
   
   Addressed in commit f0a309dee2e:
   
   1. **Unified Helper in `SparkStrategies.Aggregation`**: Extracted a local 
helper `evalDistinctChildren` that unwraps `SortOrder` before filtering 
foldables (`ae.aggregateFunction.children.flatMap { case s: SortOrder => 
s.children; case e => Seq(e) }.filterNot(_.foldable)`). Both 
`distinctAggChildSets` (sanity check) and `distinctExpressions` 
(single-distinct key) now share this helper, ensuring they cannot drift apart.
   2. **Constant Key & Delimiter**: For grouped ordered distinct aggregates 
whose constant argument equals the delimiter (e.g. `listagg(DISTINCT ',', ',') 
WITHIN GROUP (ORDER BY ',')`), the constant is now properly recognized as 
foldable and dropped from the single-distinct key, preventing the delimiter 
literal from being erroneously substituted during planning.
   3. **Test Coverage**: Added test cases in `DataFrameAggregateSuite` covering:
      - Grouped `LISTAGG` listed before `COUNT(DISTINCT ',')` where argument 
equals delimiter.
      - Grouped ordered `LISTAGG` listed before unordered `LISTAGG` with 
argument equal to delimiter.
      - Lone grouped `LISTAGG` with argument equal to delimiter.
      - Projected literal column equal to delimiter.
      - Global constant-only ordered `LISTAGG` on empty input (alone and with 
`sum(v)`, returning `NULL`) and non-empty input (alone and with `sum(v)`, 
returning `','`).
   
   All unit and end-to-end tests 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