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

[GitHub] [arrow-datafusion] izveigor opened a new pull request, #6986: feat: array functions treat an array as an element

izveigor opened a new pull request, #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes https://github.com/apache/arrow-datafusion/issues/6985
   Follow on to https://github.com/apache/arrow-datafusion/pull/6879
   Follow on to https://github.com/apache/arrow-datafusion/pull/6805
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   Yes
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   Yes
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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


[GitHub] [arrow-datafusion] jayzhan211 commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1266031831


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails
-# array_concat column-wise #10 (1D + 2D)
-# 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
-# select array_concat(make_array(column3), column4) from arrays_values_v2;
+# array_concat column-wise #9 (2D + 1D)
+query ?
+select array_concat(column4, make_array(column3)) from arrays_values_v2;

Review Comment:
   Does 1D + 2D pass? Do only descending-order dimensions work?



-- 
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


[GitHub] [arrow-datafusion] izveigor commented on pull request #6986: feat: array functions treat an array as an element

Posted by "izveigor (via GitHub)" <gi...@apache.org>.
izveigor commented on PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#issuecomment-1637849146

   Ready for the review, @alamb and @jayzhan211!
   When I was writing the code, I found new bugs related to the topic of arrays: https://github.com/apache/arrow-datafusion/issues/6993 and https://github.com/apache/arrow-datafusion/issues/6992.


-- 
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


[GitHub] [arrow-datafusion] izveigor commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "izveigor (via GitHub)" <gi...@apache.org>.
izveigor commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1265157934


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails
-# array_concat column-wise #10 (1D + 2D)
-# 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
-# select array_concat(make_array(column3), column4) from arrays_values_v2;
+# array_concat column-wise #9 (2D + 1D)
+query ?
+select array_concat(column4, make_array(column3)) from arrays_values_v2;
+----
+[[30, 40, 50], [12]]
+[[, , 60], [13]]
+[[70, , ], [14]]
+[[]]
+[[]]
+[[]]
+
+# array_concat column-wise #10 (3D + 2D + 1D)

Review Comment:
   When I was writing these examples, I suddenly found a bug: https://github.com/apache/arrow-datafusion/issues/6992



-- 
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


[GitHub] [arrow-datafusion] alamb merged pull request #6986: feat: array functions treat an array as an element

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986


-- 
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


[GitHub] [arrow-datafusion] izveigor commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "izveigor (via GitHub)" <gi...@apache.org>.
izveigor commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1265144992


##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -543,7 +545,18 @@ fn align_array_dimensions(args: Vec<ArrayRef>) -> Result<Vec<ArrayRef>> {
                 let mut aligned_array = array.clone();
                 for _ in 0..(max_ndim - ndim) {
                     let data_type = aligned_array.as_ref().data_type().clone();
-                    aligned_array = array_array(&[aligned_array], data_type)?;
+                    let offsets: Vec<i32> =
+                        (0..downcast_arg!(aligned_array, ListArray).offsets().len())
+                            .map(|i| i as i32)
+                            .collect();
+                    let field = Arc::new(Field::new("item", data_type, true));
+
+                    aligned_array = Arc::new(ListArray::try_new(

Review Comment:
   Is there a method how to push `NULL`s into `ListArray::try_new` with saving values? 🤔
   @tustvold, can you give me some advice if you have free time.



##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -543,7 +545,18 @@ fn align_array_dimensions(args: Vec<ArrayRef>) -> Result<Vec<ArrayRef>> {
                 let mut aligned_array = array.clone();
                 for _ in 0..(max_ndim - ndim) {
                     let data_type = aligned_array.as_ref().data_type().clone();
-                    aligned_array = array_array(&[aligned_array], data_type)?;
+                    let offsets: Vec<i32> =
+                        (0..downcast_arg!(aligned_array, ListArray).offsets().len())
+                            .map(|i| i as i32)
+                            .collect();
+                    let field = Arc::new(Field::new("item", data_type, true));
+
+                    aligned_array = Arc::new(ListArray::try_new(

Review Comment:
   Is there a method how to push `NULL`s into `ListArray::try_new` with saving values? 🤔
   @tustvold, can you give me some advice if you have free time.



-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #6986: feat: array functions treat an array as an element

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#issuecomment-1638923033

   Thank you for this PR @izveigor  -- I ran out of time today but I have this PR on my list to review tomorrow


-- 
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


[GitHub] [arrow-datafusion] izveigor commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "izveigor (via GitHub)" <gi...@apache.org>.
izveigor commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1265142387


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails

Review Comment:
   I was able to solve this problem.
   cc @jayzhan211



-- 
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


[GitHub] [arrow-datafusion] izveigor commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "izveigor (via GitHub)" <gi...@apache.org>.
izveigor commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1265165845


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails
-# array_concat column-wise #10 (1D + 2D)
-# 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
-# select array_concat(make_array(column3), column4) from arrays_values_v2;
+# array_concat column-wise #9 (2D + 1D)
+query ?
+select array_concat(column4, make_array(column3)) from arrays_values_v2;

Review Comment:
   When I was trying to use `make_array` with lists, I accidentally found a new bug: https://github.com/apache/arrow-datafusion/issues/6993



-- 
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


[GitHub] [arrow-datafusion] jayzhan211 commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1266046670


##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -543,7 +545,18 @@ fn align_array_dimensions(args: Vec<ArrayRef>) -> Result<Vec<ArrayRef>> {
                 let mut aligned_array = array.clone();
                 for _ in 0..(max_ndim - ndim) {
                     let data_type = aligned_array.as_ref().data_type().clone();
-                    aligned_array = array_array(&[aligned_array], data_type)?;
+                    let offsets: Vec<i32> =
+                        (0..downcast_arg!(aligned_array, ListArray).offsets().len())
+                            .map(|i| i as i32)
+                            .collect();
+                    let field = Arc::new(Field::new("item", data_type, true));
+
+                    aligned_array = Arc::new(ListArray::try_new(

Review Comment:
   There are `downcast_arg()` in this file, `as_list_array` in `datafusion/common/src/cast.rs` and `as_list, as_list_opt` in arrow-array. Which one to use among these methods?



-- 
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


[GitHub] [arrow-datafusion] jayzhan211 commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1266043363


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails
-# array_concat column-wise #10 (1D + 2D)
-# 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
-# select array_concat(make_array(column3), column4) from arrays_values_v2;
+# array_concat column-wise #9 (2D + 1D)
+query ?
+select array_concat(column4, make_array(column3)) from arrays_values_v2;
+----
+[[30, 40, 50], [12]]
+[[, , 60], [13]]
+[[70, , ], [14]]
+[[]]
+[[]]
+[[]]
+
+# array_concat column-wise #10 (3D + 2D + 1D)
+query ?
+select array_concat(column4, column1, column2) from nested_arrays;
+----
+[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]], [[1, 2, 3], [2, 9, 1], [7, 8, 9], [1, 2, 3], [1, 7, 4], [4, 5, 6]], [[7, 8, 9]]]
+[[[11, 12, 13], [14, 15, 16]], [[17, 18, 19], [20, 21, 22]], [[4, 5, 6], [10, 11, 12], [4, 9, 8], [7, 8, 9], [10, 11, 12], [1, 8, 7]], [[10, 11, 12]]]
 
-# array_concat column-wise #11 (1D + Integers)

Review Comment:
   I think we don't need to support this.



-- 
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


[GitHub] [arrow-datafusion] jayzhan211 commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1266046670


##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -543,7 +545,18 @@ fn align_array_dimensions(args: Vec<ArrayRef>) -> Result<Vec<ArrayRef>> {
                 let mut aligned_array = array.clone();
                 for _ in 0..(max_ndim - ndim) {
                     let data_type = aligned_array.as_ref().data_type().clone();
-                    aligned_array = array_array(&[aligned_array], data_type)?;
+                    let offsets: Vec<i32> =
+                        (0..downcast_arg!(aligned_array, ListArray).offsets().len())
+                            .map(|i| i as i32)
+                            .collect();
+                    let field = Arc::new(Field::new("item", data_type, true));
+
+                    aligned_array = Arc::new(ListArray::try_new(

Review Comment:
   There are `downcast_arg()` in this file, `as_list_array` in `datafusion/common/src/cast.rs` and `as_list, as_list_opt` in arrow-array. Which one to use among these methods?



-- 
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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1267305845


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -55,6 +55,13 @@ AS VALUES
   (make_array(make_array(15, 16),make_array(NULL, 18)), make_array(16.6, 17.7, 18.8), NULL)
 ;
 
+statement ok
+CREATE TABLE nested_arrays
+AS VALUES
+  (make_array(make_array(1, 2, 3), make_array(2, 9, 1), make_array(7, 8, 9), make_array(1, 2, 3), make_array(1, 7, 4), make_array(4, 5, 6)), make_array(7, 8, 9), 2, make_array([[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]])),

Review Comment:
   I recommend adding NULL values -- both as elements as well as the arrays as that is often a corner case that gets overlooked
   
   Perhaps something like 
   
   ```suggestion
     (make_array(make_array(1, 2, 3), NULL, make_array(7, 8, 9), make_array(1, 2, 3), make_array(1, 7, 4), make_array(4, 5, 6)), make_array(7, 8, 9), 2, make_array([[NULL, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]])),
   ```



##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -543,7 +545,18 @@ fn align_array_dimensions(args: Vec<ArrayRef>) -> Result<Vec<ArrayRef>> {
                 let mut aligned_array = array.clone();
                 for _ in 0..(max_ndim - ndim) {
                     let data_type = aligned_array.as_ref().data_type().clone();
-                    aligned_array = array_array(&[aligned_array], data_type)?;
+                    let offsets: Vec<i32> =
+                        (0..downcast_arg!(aligned_array, ListArray).offsets().len())
+                            .map(|i| i as i32)
+                            .collect();
+                    let field = Arc::new(Field::new("item", data_type, true));
+
+                    aligned_array = Arc::new(ListArray::try_new(

Review Comment:
   The last argument to `try_new` is the `Option<NullBuffer>` right which defines which elements are nulls.
   
   Perhaps I don't understand your question



-- 
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


[GitHub] [arrow-datafusion] izveigor commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "izveigor (via GitHub)" <gi...@apache.org>.
izveigor commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1265156556


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails
-# array_concat column-wise #10 (1D + 2D)
-# 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
-# select array_concat(make_array(column3), column4) from arrays_values_v2;
+# array_concat column-wise #9 (2D + 1D)
+query ?
+select array_concat(column4, make_array(column3)) from arrays_values_v2;
+----
+[[30, 40, 50], [12]]
+[[, , 60], [13]]
+[[70, , ], [14]]
+[[]]
+[[]]
+[[]]
+
+# array_concat column-wise #10 (3D + 2D + 1D)
+query ?
+select array_concat(column4, column1, column2) from nested_arrays;
+----
+[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]], [[1, 2, 3], [2, 9, 1], [7, 8, 9], [1, 2, 3], [1, 7, 4], [4, 5, 6]], [[7, 8, 9]]]
+[[[11, 12, 13], [14, 15, 16]], [[17, 18, 19], [20, 21, 22]], [[4, 5, 6], [10, 11, 12], [4, 9, 8], [7, 8, 9], [10, 11, 12], [1, 8, 7]], [[10, 11, 12]]]
 
-# array_concat column-wise #11 (1D + Integers)

Review Comment:
   It seems like the regression, but PostgreSQL does not support concatenation between scalars (integers) and arrays.
   Should we keep this feature or is it better to follow the PostgreSQL standard? 🤔
   What do you think about it, @jayzhan211?



##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails
-# array_concat column-wise #10 (1D + 2D)
-# 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
-# select array_concat(make_array(column3), column4) from arrays_values_v2;
+# array_concat column-wise #9 (2D + 1D)
+query ?
+select array_concat(column4, make_array(column3)) from arrays_values_v2;
+----
+[[30, 40, 50], [12]]
+[[, , 60], [13]]
+[[70, , ], [14]]
+[[]]
+[[]]
+[[]]
+
+# array_concat column-wise #10 (3D + 2D + 1D)
+query ?
+select array_concat(column4, column1, column2) from nested_arrays;
+----
+[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]], [[1, 2, 3], [2, 9, 1], [7, 8, 9], [1, 2, 3], [1, 7, 4], [4, 5, 6]], [[7, 8, 9]]]
+[[[11, 12, 13], [14, 15, 16]], [[17, 18, 19], [20, 21, 22]], [[4, 5, 6], [10, 11, 12], [4, 9, 8], [7, 8, 9], [10, 11, 12], [1, 8, 7]], [[10, 11, 12]]]
 
-# array_concat column-wise #11 (1D + Integers)

Review Comment:
   It seems like the regression, but PostgreSQL does not support concatenation between scalars (integers) and arrays.
   Should we keep this feature or is it better to follow the PostgreSQL standard? 🤔
   What do you think about it, @jayzhan211?



-- 
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


[GitHub] [arrow-datafusion] jayzhan211 commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1266031831


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails
-# array_concat column-wise #10 (1D + 2D)
-# 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
-# select array_concat(make_array(column3), column4) from arrays_values_v2;
+# array_concat column-wise #9 (2D + 1D)
+query ?
+select array_concat(column4, make_array(column3)) from arrays_values_v2;

Review Comment:
   Does 1D + 2D pass? or only descending order dimensions works?



-- 
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


[GitHub] [arrow-datafusion] jayzhan211 commented on a diff in pull request #6986: feat: array functions treat an array as an element

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#discussion_r1266031831


##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -554,28 +595,36 @@ select array_concat(column1, column2) from arrays_values_v2;
 [11, 12]
 NULL
 
-# TODO: Concat columns with different dimensions fails
-# array_concat column-wise #10 (1D + 2D)
-# 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
-# select array_concat(make_array(column3), column4) from arrays_values_v2;
+# array_concat column-wise #9 (2D + 1D)
+query ?
+select array_concat(column4, make_array(column3)) from arrays_values_v2;

Review Comment:
   Does 1D + 2D pass?



-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #6986: feat: array functions treat an array as an element

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6986:
URL: https://github.com/apache/arrow-datafusion/pull/6986#issuecomment-1641000477

   Thanks @izveigor  and @jayzhan211 


-- 
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