bersprockets opened a new pull request #35851:
URL: https://github.com/apache/spark/pull/35851
Backport of #35837.
### What changes were proposed in this pull request?
When building the project list from an aggregate sequence in
`ExtractGenerator`, convert the aggregate sequence to an `IndexedSeq` before
performing the flatMap operation.
### Why are the changes needed?
This query fails with a `NullPointerException`:
```
val df = Seq(1, 2, 3).toDF("v")
df.select(Stream(explode(array(min($"v"), max($"v"))), sum($"v")):
_*).collect
```
If you change `Stream` to `Seq`, then it succeeds.
`ExtractGenerator` uses a flatMap operation over `aggList` for two purposes:
- To produce a new aggregate list
- to update `projectExprs` (which is initialized as an array of nulls).
When `aggList` is a `Stream`, the flatMap operation evaluates lazily, so all
entries in `projectExprs` after the first will still be null when the rule
completes.
Changing `aggList` to an `IndexedSeq` forces the flatMap to evaluate eagerly.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
New unit test
--
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]