fix: audit array_insert expression for correctness and test coverage#3890
Open
andygrove wants to merge 3 commits intoapache:mainfrom
Open
fix: audit array_insert expression for correctness and test coverage#3890andygrove wants to merge 3 commits intoapache:mainfrom
andygrove wants to merge 3 commits intoapache:mainfrom
Conversation
Fix nullable() metadata bug in ArrayInsert where only src_array_expr was checked but not pos_expr, causing incorrect nullability reporting when the position column is nullable. Expand SQL test coverage from 1 query to 27+ queries across multiple types and edge cases.
Member
Author
|
@kazuyukitanimura @martin-g This PR was created using the audit skill that you reviewed |
andygrove
commented
Apr 3, 2026
| under the License. | ||
| --> | ||
|
|
||
| # Expression Audit Log |
Member
Author
There was a problem hiding this comment.
I think it is important to keep track of which expressions have been audited and against which Spark versions. Maintaining a markdown doc is one approach. Another approach could be to add comments and/or annotations directly in the code in the serde handlers.
martin-g
approved these changes
Apr 3, 2026
Member
Really cool! |
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?
N/A - proactive audit of existing expression.
Rationale for this change
Audited the
array_insertexpression against Spark 3.4.3, 3.5.8, and 4.0.1 source code to verify correctness and identify test coverage gaps. Found a metadata bug and significant missing test coverage.What changes are included in this PR?
Bug fix:
nullable()inArrayInsert(Rust) to account forpos_exprnullability, matching Spark'sfirst.nullable | second.nullable. Previously only checkedsrc_array_expr, so if the position column was nullable but the array was not, the metadata incorrectly reported "not nullable".Test coverage (expanded from 1 query to 27+ queries):
spark.sql.legacy.negativeIndexInArrayInsert=true) in a separate test fileDocumentation:
docs/source/contributor-guide/expression-audit-log.mdto track audited expressionsHow are these changes tested?
All new SQL file tests pass against both Spark and Comet:
Rust unit tests and clippy pass. Full build succeeds.