rdtr opened a new pull request, #13258:
URL: https://github.com/apache/gluten/pull/13258

   ## What changes are proposed in this pull request?
   
   Spark 4.2 supports `collect_set(x) RESPECT NULLS` (SPARK-55533). 
`CollectRewriteRule` already keeps the flag in `VeloxCollectSet.ignoreNulls` 
(from #11891), but only the column was passed to Velox, so Velox ignored the 
nulls:
   
   ```
   SELECT sort_array(collect_set(b) RESPECT NULLS) FROM ...
   -- Spark: [null, 2]
   -- Gluten: [2]
   ```
   
   This PR passes `false` as the second, constant argument of Velox's 
`collect_set` when `ignoreNulls` is false. The default, IGNORE NULLS, keeps the 
one-argument form, so nothing changes for existing queries.
   
   This also needs a Velox fix: Gluten runs the partial step as 
`collect_set_partial`, and Velox's companion functions didn't pass constant 
arguments to the wrapped aggregate. That is fixed in 
https://github.com/facebookincubator/velox/pull/19464. This PR stays a draft 
until the fix is in the Velox version Gluten uses.
   
   Window functions (`collect_set(x) RESPECT NULLS OVER (...)`) are not covered 
by this PR. They need https://github.com/facebookincubator/velox/pull/19473 and 
a change in Gluten's window path, which I'll do in a follow-up.
   
   Part of #13176
   
   ## How was this patch tested?
   
   Added a Spark 4.2 test to `VeloxAggregateFunctionsSuite` that compares 
`collect_set(b) RESPECT NULLS` with vanilla Spark, with and without GROUP BY. I 
checked the Substrait plan: the partial aggregation calls `collect_set` with 
the column and the literal `false`. With the current Velox version the test 
fails because of the companion function issue above.
   
   ## Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 5.5)
   


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