Skip to content

[SPARK-55747][SQL] Fix NPE when accessing elements from an array that is null#54546

Open
stevomitric wants to merge 3 commits intoapache:masterfrom
stevomitric:stevomitric/fix-npe-codegen
Open

[SPARK-55747][SQL] Fix NPE when accessing elements from an array that is null#54546
stevomitric wants to merge 3 commits intoapache:masterfrom
stevomitric:stevomitric/fix-npe-codegen

Conversation

@stevomitric
Copy link
Contributor

What changes were proposed in this pull request?

The GetArrayItem expression incorrectly computed nullable = false when indexing into arrays with containsNull = false (e.g., from split()), even when the array itself could be null. This caused codegen to skip null checks, leading to NPE on array.numElements() during bounds checking.

Why are the changes needed?

To resolve NPE within spark engine.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Tests in this PR.

Was this patch authored or co-authored using generative AI tooling?

No

@stevomitric
Copy link
Contributor Author

cc @cloud-fan to PTAL

@stevomitric stevomitric changed the title [SPARK-55747] Fix NPE when accessing elements from an array that is null [SPARK-55747][SQL] Fix NPE when accessing elements from an array that is null Feb 27, 2026
Co-authored-by: YangJie <yangjie01@baidu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants