@@ -68,6 +68,17 @@ AS VALUES
6868 (make_array(61, 62, 63, 64, 65, 66, 67, 68, 69, 70), 66, 7, NULL)
6969;
7070
71+ statement ok
72+ CREATE TABLE arrays_values_v2
73+ AS VALUES
74+ (make_array(NULL, 2, 3), make_array(4, 5, NULL), 12, make_array([30, 40, 50])),
75+ (NULL, make_array(7, NULL, 8), 13, make_array(make_array(NULL,NULL,60))),
76+ (make_array(9, NULL, 10), NULL, 14, make_array(make_array(70,NULL,NULL))),
77+ (make_array(NULL, 1), make_array(NULL, 21), NULL, NULL),
78+ (make_array(11, 12), NULL, NULL, NULL),
79+ (NULL, NULL, NULL, NULL)
80+ ;
81+
7182statement ok
7283CREATE TABLE arrays_values_without_nulls
7384AS VALUES
@@ -116,6 +127,16 @@ NULL 44 5 @
116127[51, 52, , 54, 55, 56, 57, 58, 59, 60] 55 NULL ^
117128[61, 62, 63, 64, 65, 66, 67, 68, 69, 70] 66 7 NULL
118129
130+ query ??I?
131+ select column1, column2, column3, column4 from arrays_values_v2;
132+ ----
133+ [, 2, 3] [4, 5, ] 12 [[30, 40, 50]]
134+ NULL [7, , 8] 13 [[, , 60]]
135+ [9, , 10] NULL 14 [[70, , ]]
136+ [, 1] [, 21] NULL NULL
137+ [11, 12] NULL NULL NULL
138+ NULL NULL NULL NULL
139+
119140# arrays_values_without_nulls table
120141query ?II
121142select column1, column2, column3 from arrays_values_without_nulls;
@@ -423,6 +444,148 @@ select array_concat(make_array(10, 20), make_array([30, 40]), make_array([[50, 6
423444----
424445[[[10, 20]], [[30, 40]], [[50, 60]]]
425446
447+ # array_concat column-wise #1
448+ query ?
449+ select array_concat(column1, make_array(0)) from arrays_values_without_nulls;
450+ ----
451+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]
452+ [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0]
453+ [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0]
454+ [31, 32, 33, 34, 35, 26, 37, 38, 39, 40, 0]
455+
456+ # array_concat column-wise #2
457+ query ?
458+ select array_concat(column1, column1) from arrays_values_without_nulls;
459+ ----
460+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
461+ [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
462+ [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
463+ [31, 32, 33, 34, 35, 26, 37, 38, 39, 40, 31, 32, 33, 34, 35, 26, 37, 38, 39, 40]
464+
465+ # array_concat column-wise #3
466+ query ?
467+ select array_concat(make_array(column2), make_array(column3)) from arrays_values_without_nulls;
468+ ----
469+ [1, 1]
470+ [12, 2]
471+ [23, 3]
472+ [34, 4]
473+
474+ # array_concat column-wise #4
475+ query ?
476+ select array_concat(column1, column2) from arrays_values;
477+ ----
478+ [, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]
479+ [11, 12, 13, 14, 15, 16, 17, 18, , 20, 12]
480+ [21, 22, 23, , 25, 26, 27, 28, 29, 30, 23]
481+ [31, 32, 33, 34, 35, , 37, 38, 39, 40, 34]
482+ [44]
483+ [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, ]
484+ [51, 52, , 54, 55, 56, 57, 58, 59, 60, 55]
485+ [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 66]
486+
487+ # array_concat column-wise #5
488+ query ?
489+ select array_concat(make_array(column2), make_array(0)) from arrays_values;
490+ ----
491+ [1, 0]
492+ [12, 0]
493+ [23, 0]
494+ [34, 0]
495+ [44, 0]
496+ [, 0]
497+ [55, 0]
498+ [66, 0]
499+
500+ # array_concat column-wise #6
501+ query ???
502+ select array_concat(column1, column1), array_concat(column2, column2), array_concat(column3, column3) from arrays;
503+ ----
504+ [[, 2], [3, ], [, 2], [3, ]] [1.1, 2.2, 3.3, 1.1, 2.2, 3.3] [L, o, r, e, m, L, o, r, e, m]
505+ [[3, 4], [5, 6], [3, 4], [5, 6]] [, 5.5, 6.6, , 5.5, 6.6] [i, p, , u, m, i, p, , u, m]
506+ [[5, 6], [7, 8], [5, 6], [7, 8]] [7.7, 8.8, 9.9, 7.7, 8.8, 9.9] [d, , l, o, r, d, , l, o, r]
507+ [[7, ], [9, 10], [7, ], [9, 10]] [10.1, , 12.2, 10.1, , 12.2] [s, i, t, s, i, t]
508+ NULL [13.3, 14.4, 15.5, 13.3, 14.4, 15.5] [a, m, e, t, a, m, e, t]
509+ [[11, 12], [13, 14], [11, 12], [13, 14]] NULL [,, ,]
510+ [[15, 16], [, 18], [15, 16], [, 18]] [16.6, 17.7, 18.8, 16.6, 17.7, 18.8] NULL
511+
512+ # array_concat column-wise #7
513+ query ??
514+ select array_concat(column1, make_array(make_array(1, 2), make_array(3, 4))), array_concat(column2, make_array(1.1, 2.2, 3.3)) from arrays;
515+ ----
516+ [[, 2], [3, ], [1, 2], [3, 4]] [1.1, 2.2, 3.3, 1.1, 2.2, 3.3]
517+ [[3, 4], [5, 6], [1, 2], [3, 4]] [, 5.5, 6.6, 1.1, 2.2, 3.3]
518+ [[5, 6], [7, 8], [1, 2], [3, 4]] [7.7, 8.8, 9.9, 1.1, 2.2, 3.3]
519+ [[7, ], [9, 10], [1, 2], [3, 4]] [10.1, , 12.2, 1.1, 2.2, 3.3]
520+ [[1, 2], [3, 4]] [13.3, 14.4, 15.5, 1.1, 2.2, 3.3]
521+ [[11, 12], [13, 14], [1, 2], [3, 4]] [1.1, 2.2, 3.3]
522+ [[15, 16], [, 18], [1, 2], [3, 4]] [16.6, 17.7, 18.8, 1.1, 2.2, 3.3]
523+
524+ # array_concat column-wise #8
525+ query ?
526+ select array_concat(column3, make_array('.', '.', '.')) from arrays;
527+ ----
528+ [L, o, r, e, m, ., ., .]
529+ [i, p, , u, m, ., ., .]
530+ [d, , l, o, r, ., ., .]
531+ [s, i, t, ., ., .]
532+ [a, m, e, t, ., ., .]
533+ [,, ., ., .]
534+ [., ., .]
535+
536+ # query ??I?
537+ # select column1, column2, column3, column4 from arrays_values_v2;
538+ # ----
539+ # [, 2, 3] [4, 5, ] 12 [[30, 40, 50]]
540+ # NULL [7, , 8] 13 [[, , 60]]
541+ # [9, , 10] NULL 14 [[70, , ]]
542+ # [, 1] [, 21] NULL NULL
543+ # [11, 12] NULL NULL NULL
544+ # NULL NULL NULL NULL
545+
546+ # array_concat column-wise #9 (1D + 1D)
547+ query ?
548+ select array_concat(column1, column2) from arrays_values_v2;
549+ ----
550+ [, 2, 3, 4, 5, ]
551+ [7, , 8]
552+ [9, , 10]
553+ [, 1, , 21]
554+ [11, 12]
555+ NULL
556+
557+ # TODO: Concat columns with different dimensions fails
558+ # array_concat column-wise #10 (1D + 2D)
559+ # query error DataFusion error: Arrow error: Invalid argument error: column types must match schema types, expected List\(Field \{ name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: \{\} \}\) but found List\(Field \{ name: "item", data_type: List\(Field \{ name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: \{\} \}\), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: \{\} \}\) at column index 0
560+ # select array_concat(make_array(column3), column4) from arrays_values_v2;
561+
562+ # array_concat column-wise #11 (1D + Integers)
563+ query ?
564+ select array_concat(column2, column3) from arrays_values_v2;
565+ ----
566+ [4, 5, , 12]
567+ [7, , 8, 13]
568+ [14]
569+ [, 21, ]
570+ []
571+ []
572+
573+ # TODO: Panic at 'range end index 3 out of range for slice of length 2'
574+ # array_concat column-wise #12 (2D + 1D)
575+ # query
576+ # select array_concat(column4, column1) from arrays_values_v2;
577+
578+ # array_concat column-wise #13 (1D + 1D + 1D)
579+ query ?
580+ select array_concat(make_array(column3), column1, column2) from arrays_values_v2;
581+ ----
582+ [12, , 2, 3, 4, 5, ]
583+ [13, 7, , 8]
584+ [14, 9, , 10]
585+ [, , 1, , 21]
586+ [, 11, 12]
587+ []
588+
426589## array_position
427590
428591# array_position scalar function #1
@@ -835,6 +998,7 @@ select make_array(f0) from fixed_size_list_array
835998[[1, 2], [3, 4]]
836999
8371000
1001+
8381002### Delete tables
8391003
8401004
0 commit comments