Skip to content

Commit d96fbde

Browse files
authored
fix: null padding for array_reverse on FixedSizeList (#17673)
* fix: array_reverse with null * update * update
1 parent 523eadd commit d96fbde

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

datafusion/functions-nested/src/reverse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn fixed_size_array_reverse(
199199
// skip the null value
200200
if array.is_null(row_index) {
201201
nulls.push(false);
202-
mutable.extend(0, 0, 1);
202+
mutable.extend(0, 0, value_length);
203203
continue;
204204
} else {
205205
nulls.push(true);

datafusion/sqllogictest/test_files/array.slt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8026,6 +8026,23 @@ NULL NULL
80268026
[60, 59, 58, 57, 56, 55, 54, NULL, 52, 51] [51, 52, NULL, 54, 55, 56, 57, 58, 59, 60]
80278027
[70, 69, 68, 67, 66, 65, 64, 63, 62, 61] [61, 62, 63, 64, 65, 66, 67, 68, 69, 70]
80288028

8029+
statement ok
8030+
CREATE TABLE test_reverse_fixed_size AS VALUES
8031+
(arrow_cast([1, 2, 3], 'FixedSizeList(3, Int64)')),
8032+
(arrow_cast([4, 5, 6], 'FixedSizeList(3, Int64)')),
8033+
(arrow_cast([NULL, 8, 9], 'FixedSizeList(3, Int64)')),
8034+
(NULL);
8035+
8036+
query ?
8037+
SELECT array_reverse(column1) FROM test_reverse_fixed_size;
8038+
----
8039+
[3, 2, 1]
8040+
[6, 5, 4]
8041+
[9, 8, NULL]
8042+
NULL
8043+
8044+
statement ok
8045+
DROP TABLE test_reverse_fixed_size;
80298046

80308047
# Test defining a table with array columns
80318048
statement ok

0 commit comments

Comments
 (0)