Repository navigation
Conversation
Areesha-Rizwan412
approved these changes
Dec 5, 2026
Areesha-Rizwan412
left a comment
There was a problem hiding this comment.
Verified at head a6e0bac against #28020.
The guard placement is right: in compute_array_length the current_dimension == dimension check still returns value.len() first, so an empty list at the requested dimension returns 0, and the new value.is_empty() check only fires when descending further, returning NULL instead of panicking on .value(0). Since the guard sits before the type match, it covers all three descent sites (ListArray, LargeListArray, FixedSizeListArray) in one place.
That matches the existing behavior for array_length(make_array(), 2) returning NULL, and the new sqllogictest covers List, LargeList, and a three-level nesting, which pins the deeper-dimension case from the issue.
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?
Rationale for this change
array_lengthpanics withindex out of bounds: the len is 1 but the index is 1when a row is an empty list of lists and the requested dimension is deeper than the empty level:It should return
NULL, likearray_length(make_array(), 2)already does.What changes are included in this PR?
compute_array_lengthsteps into deeper dimensions with.value(0), which panics on an empty list. It now returnsNULLwhen the current level is empty and the requested dimension is deeper:if current_dimension == dimension { return Ok(Some(value.len() as u64)); } + if value.is_empty() { + return Ok(None); + }The check comes after the dimension match, so the length of an empty level itself is still
0(for examplearray_length([], 1) = 0). One check coversList,LargeListandFixedSizeList.This is separate from #27860, which is about whether a zero length should become
NULL. That PR does not touch the.value(0)call that panics here.What is the testing strategy for this PR?
New
sqllogictestcase inarray/array_length.slt:List(List(Int64))0(unchanged)List(List(Int64))NULLLargeList(List(Int64))NULL[[]]asList(List(List(Int64)))NULLWithout the fix this query panics with
index out of bounds: the len is 1 but the index is 1. With the fix it passes, and the otherarray/*.sltfiles and thelengthunit tests still pass.Are there any user-facing changes?
array_lengthreturnsNULLinstead of panicking for these inputs. No API changes.