andygrove commented on PR #4720: URL: https://github.com/apache/datafusion-comet/pull/4720#issuecomment-5005033208
This guard is for `RESPECT NULLS` (`ignoreNulls = false`), not `IGNORE NULLS`, and it only becomes reachable on Spark 4.2. Spark 4.2 added an `ignoreNulls` field to `CollectList`/`CollectSet`. `FunctionResolution.applyIgnoreNulls` now has explicit cases for them: ```scala case collectList: CollectList => collectList.copy(ignoreNulls = ignoreNulls) case collectSet: CollectSet => collectSet.copy(ignoreNulls = ignoreNulls) ``` so `SELECT collect_list(c) RESPECT NULLS FROM ...` is accepted on 4.2 and produces `CollectList(ignoreNulls = false)`, whose buffer preserves nulls (`bufferContainsNull = !ignoreNulls`). Comet's native aggregate always drops nulls, so it has to fall back in that case, which is what this branch does. Your `IGNORE NULLS` example throws because it runs on Spark 4.1 or earlier, where `CollectList` isn't in the `applyIgnoreNulls` match and instead hits `case _ if ignoreNulls => throw ... "IGNORE NULLS"`. On those versions the field doesn't exist, so `CometCollectShim` hardcodes `ignoreNulls = true` and this branch is an unreachable no-op. It's routed through the shim precisely so it only activates on 4.2. (On 4.2 your exact `IGNORE NULLS` query is actually accepted too, since it resolves to the default.) I'll add a 4.2-only SQL test exercising `collect_list(c) RESPECT NULLS` plus a code comment spelling out the version split so this is clearer in the source. For transparency: I used an LLM to help trace the Spark 4.2 resolution path while working through this. -- 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]
