apache / apache/datafusion-comet
Support inline and stack generators in GenerateExec
- Dominant language
- Scala
- Stars
- 1.3k
- Forks
- 373
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 198
Description
### What is the problem the feature request solves?
`GenerateExec` runs natively for `explode` and `posexplode` over arrays, but the `inline` and `stack` generators fall back to Spark, taking the surrounding stage with them.
Flattening nested data is a staple of ETL over semi-structured sources: `inline` is the idiomatic way to expand an array of structs into columns, and `stack` is the standard unpivot. Both commonly appear directly above a Parquet scan, so the fallback lands on exactly the stages Comet otherwise accelerates well.
### Describe the potential solution
- `inline(array)` is `explode` followed by flattening the struct fields into top-level columns, so it should be able to reuse the existing native explode machinery plus a projection.
- `stack(n, expr1, ..., exprk)` is a constant-shape row expansion and does not depend on array input at all.
`explode_outer` support is tracked separately in #2838; the `_outer` variants of `inline` would follow the same null-row semantics.
### Additional context
Related: #2838 (`explode_outer`), #4269 (added `posexplode` / `posexplode_outer`).
Contributor guide
Research direction
Start by tracing GenerateExec's existing native explode and posexplode paths, then read the related work in #4269 and #2838 for generator behavior and null semantics. Implement native handling for inline and stack, and verify that queries using them no longer fall back to Spark around the affected stage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala, spark
- Domain
- data-engineering
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100