You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jayzhan211 (via GitHub)" <gi...@apache.org> on 2023/07/11 05:34:24 UTC

[GitHub] [arrow-datafusion] jayzhan211 commented on a diff in pull request #6879: Column support for array concat

jayzhan211 commented on code in PR #6879:
URL: https://github.com/apache/arrow-datafusion/pull/6879#discussion_r1259207958


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -389,6 +406,115 @@ select array_concat(make_array(10, 20), make_array([30, 40]), make_array([[50, 6
 ----
 [[[10, 20]], [[30, 40]], [[50, 60]]]
 
+# array_concat column-wise #1
+query ?
+select array_concat(column1, make_array(0)) from arrays_values_without_nulls;
+----
+[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]
+[11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0]
+[21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0]
+[31, 32, 33, 34, 35, 26, 37, 38, 39, 40, 0]
+
+# array_concat column-wise #2
+query ?
+select array_concat(column1, column1) from arrays_values_without_nulls;
+----
+[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+[11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
+[21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
+[31, 32, 33, 34, 35, 26, 37, 38, 39, 40, 31, 32, 33, 34, 35, 26, 37, 38, 39, 40]
+
+# array_concat column-wise #3
+query ?
+select array_concat(make_array(column2), make_array(column3)) from arrays_values_without_nulls;
+----
+[1, 1]
+[12, 2]
+[23, 3]
+[34, 4]
+
+# array_concat column-wise #4
+# TODO: concat with null should be empty not 0, this only fails when rhs is null.
+# query ?
+# select array_concat(column1, column2) from arrays_values;
+# ----
+# [, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]
+# [11, 12, 13, 14, 15, 16, 17, 18, , 20, 12]
+# [21, 22, 23, , 25, 26, 27, 28, 29, 30, 23]
+# [31, 32, 33, 34, 35, , 37, 38, 39, 40, 34]
+# [44]
+# [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0]
+# [51, 52, , 54, 55, 56, 57, 58, 59, 60, 55]
+# [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 66]
+#
+# query ?I
+# select column1, column2 from arrays_values;
+# ----
+# [, 2, 3, 4, 5, 6, 7, 8, 9, 10] 1
+# [11, 12, 13, 14, 15, 16, 17, 18, , 20] 12
+# [21, 22, 23, , 25, 26, 27, 28, 29, 30] 23
+# [31, 32, 33, 34, 35, , 37, 38, 39, 40] 34
+# NULL 44
+# [41, 42, 43, 44, 45, 46, 47, 48, 49, 50] NULL
+# [51, 52, , 54, 55, 56, 57, 58, 59, 60] 55
+# [61, 62, 63, 64, 65, 66, 67, 68, 69, 70] 66
+
+# TODO: NULL should be empty not 0
+# query ?
+# select array_concat(make_array(column2), make_array(0)) from arrays_values;
+# ----
+# [1, 0]
+# [12, 0]
+# [23, 0]
+# [34, 0]
+# [44, 0]
+# [0, 0]

Review Comment:
   `make_array` on the column with null values returns 0 but should be a null value instead. We can fix this in another PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org