feat: add support for posexplode and posexplode_outer#4270
Open
andygrove wants to merge 2 commits intoapache:mainfrom
Open
feat: add support for posexplode and posexplode_outer#4270andygrove wants to merge 2 commits intoapache:mainfrom
posexplode and posexplode_outer#4270andygrove wants to merge 2 commits intoapache:mainfrom
Conversation
Extend `CometExplodeExec` to accept both `Explode` and `PosExplode` Catalyst nodes. The Explode operator proto carries a new `position` flag; when set, the native planner builds a parallel `List<Int32>` positions column with `ListPositionsExpr` and unnests it alongside the array column via DataFusion's `UnnestExec`. Maps still fall back (apache#2837) and `outer=true` keeps its Incompatible status (DataFusion #19053). Closes apache#4269.
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.
Which issue does this PR close?
Closes #4269.
Rationale for this change
Comet already supports the
explodegenerator for array inputs but rejectsposexplodeandposexplode_outer, forcing a fallback to Spark for any query that needs the position column. This PR closes that gap so workloads that use theposexplode(arr) AS (pos, col)pattern (or the SQLLATERAL VIEW posexplode(...)form) stay native.What changes are included in this PR?
CometExplodeExec(Scala serde) now accepts bothExplodeandPosExplodeCatalyst nodes and propagates a newpositionflag through the operator proto.Explodeproto message gets abool positionfield (tag 4).List<Int32>positions column from a newListPositionsExprand passes it to DataFusion'sUnnestExecas a secondListUnnestentry. Output schema injectspos: Int32 not nullbefore the unnested element.ListPositionsExpr(native/core/src/execution/expressions/list_positions.rs) reuses the inputListArrayoffsets and null bitmap, populating each row with[0..len-1]. Sharing offsets with the source array is what letsUnnestExecunnest both columns in parallel without alignment drift.explode#2837) andouter=truekeeps its Incompatible status (DataFusion #19053).docs/source/user-guide/latest/operators.mdandunderstanding-comet-plans.mdupdated.The
implement-comet-expressionandaudit-comet-expressionskills were used to scaffold the implementation and follow-up coverage.How are these changes tested?
CometGenerateExecSuitewas extended with 12 new tests covering:posexplodeover arrays (simple, empty, null, strings, nullable elements)posexplode_outerover a simple array (allowIncompat=true)posexplodeover an array of structs (with field projection out of the unnested struct)posexplodein a SQLLATERAL VIEWposexplodeof a literal arrayposexplodeacross batch boundaries withspark.comet.batchSize=4to verify the parallel positions/values lists stay aligned across batchesThe existing
CometGenerateExecSuitecontinues to pass.