From add0346b92d564902b952d8509eb6f9a13bb5b6a Mon Sep 17 00:00:00 2001 From: gitccl Date: Sun, 5 May 2024 16:38:11 +0800 Subject: [PATCH] Fix ordering issue with nested list type --- .../row_operations/row_radix_scatter.cpp | 2 +- test/sql/order/issue_11936.test | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/sql/order/issue_11936.test diff --git a/src/common/row_operations/row_radix_scatter.cpp b/src/common/row_operations/row_radix_scatter.cpp index 01557ca455c..73242d13c82 100644 --- a/src/common/row_operations/row_radix_scatter.cpp +++ b/src/common/row_operations/row_radix_scatter.cpp @@ -125,7 +125,7 @@ void RadixScatterListVector(Vector &v, UnifiedVectorFormat &vdata, const Selecti key_locations[i][0] = 1; key_locations[i]++; RowOperations::RadixScatter(child_vector, list_size, *FlatVector::IncrementalSelectionVector(), 1, - key_locations + i, false, true, false, prefix_len, width - 1, + key_locations + i, false, true, false, prefix_len, width - 2, list_entry.offset); } else { // denote that the list is empty with a 0 diff --git a/test/sql/order/issue_11936.test b/test/sql/order/issue_11936.test new file mode 100644 index 00000000000..028ac5ba410 --- /dev/null +++ b/test/sql/order/issue_11936.test @@ -0,0 +1,21 @@ +# name: test/sql/order/issue_11936.test +# description: Test order nested list +# group: [order] + +statement ok +PRAGMA enable_verification + +statement ok +CREATE TABLE test(col1 INT, col2 INT2[][][][][][]); + +statement ok +INSERT INTO test VALUES(1000000000, null), (1000000001, [[[[[[]]]]]]), (null, [[[[[[]]]]]]), (null, [[[[[[]]]]]]), (1, [[[[[[]]]]]]); + +query II +SELECT col1, col2 FROM test ORDER BY col1 NULLS LAST, col2; +---- +1 [[[[[[]]]]]] +1000000000 NULL +1000000001 [[[[[[]]]]]] +NULL [[[[[[]]]]]] +NULL [[[[[[]]]]]]