feat: [branch-1.0] support explode_outer (#5192) - #5261
Merged
Conversation
(cherry picked from commit 2af9cec)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #5192 to
branch-1.0.Cherry-picked cleanly from
2af9cec38b1f68550c3e13c1109f3c7502081e84with no conflicts and no modifications — the diff is identical to the original PR.Which issue does this PR close?
Closes #2838 and #5224 on
branch-1.0.Rationale for this change
Comet previously routed
GenerateExecwithouter = trueback to Spark (Incompatible) because DataFusion'sUnnestExecwithpreserve_nulls = trueemits one null row for a NULL list but drops rows whose list is empty. Spark'sexplode_outer/posexplode_outermust emit one null row for both cases, so anything containing empty arrays fell back to JVM whole-stage codegen.What changes are included in this PR?
Native:
ListEmptyToNullExpr(native/core/src/execution/expressions/list_empty_to_null.rs) rewrites aList<T>to mark every empty row as null while preserving the original offsets, values, and column name.planner.rswraps the array child withListEmptyToNullExprwhenexplode.outeris true, before positions are computed and before the projection feedsUnnestExec.ListPositionsExprinherits the modified null bitmap soposandvaluestay aligned forposexplode_outer.Serde:
CometExplodeExec.getSupportLevelno longer returnsIncompatibleforop.outer. Unsupported cases (maps, non-deterministic generators, multi-input generators,COMET_EXEC_EXPLODE_ENABLED = false) still fall back to Spark whole-stage codegen through the standardUnsupportedpath.Tests:
explode_outer with empty array,explode_outer with nullable projected column,explode_outer with mixed null, empty, and non-empty arraysinCometGenerateExecSuite.WHERE id != 4workaround and staleallowIncompatibleConfig:directive inposexplode.sql.sql-tests/expressions/array/explode.sqlcoveringexplode/explode_outer(plusLATERAL VIEWandLATERAL VIEW OUTER) across every primitive element type, nestedarray<array<int>>,array<struct>, NULLs, literal arrays, empty tables, and anexpect_fallbackformapinput.Are these changes tested?
Yes — same tests as the original PR. Verified locally on
branch-1.0:cargo buildsucceeds and all 18list_empty_to_null/list_positions/ related Rust unit tests pass.branch-1.0pins the same DataFusion version (54.1.0) asmain, so no API adaptation was needed.Are there any user-facing changes?
explode_outerandposexplode_outernow run natively without requiringspark.comet.operator.GenerateExec.allowIncompatible = true. No behavioral change forexplode/posexplode.