kosiew commented on PR #22161: URL: https://github.com/apache/datafusion/pull/22161#issuecomment-4531064661
@Omega359 Good catch — this is a semantic regression. The current guard only proves that the first list level is a non-empty, non-null literal (`unnest_preserves_at_least_one_row_per_input` / `literal_non_empty_list`). That is not enough for recursive/nested unnest. In the example, the outer list has one element, so the guard incorrectly treats it as row-preserving, but the inner list is empty and the second unnest removes all rows before the `GROUP BY`. I’ll fix this by making the optimization more conservative for recursive list unnesting: only prune when the rule can prove every unnest step preserves at least one row. Practically, I’ll block pruning for list `UNNEST` entries with `depth > 1` unless/until we add a recursive literal proof. I’ll also add the exact SQL regression (and a unit test) so this case stays unoptimized and returns the empty result, preserving empty/null list and `preserve_nulls` behavior. -- 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]
