alamb commented on code in PR #6936:
URL: https://github.com/apache/arrow-datafusion/pull/6936#discussion_r1283637365


##########
docs/source/user-guide/expressions.md:
##########
@@ -199,10 +200,11 @@ Unlike to some databases the math functions in Datafusion 
works the same way as
 | array_replace(array, from, to)        | Replaces the first occurrence of the 
specified element with another specified element. `array_replace([1, 2, 2, 3, 
2, 1, 4], 2, 5) -> [1, 5, 2, 3, 2, 1, 4]`             |
 | array_replace_n(array, from, to, max) | Replaces the first `max` occurrences 
of the specified element with another specified element. `array_replace_n([1, 
2, 2, 3, 2, 1, 4], 2, 5, 2) -> [1, 5, 5, 3, 2, 1, 4]` |
 | array_replace_all(array, from, to)    | Replaces all occurrences of the 
specified element with another specified element. `array_replace_all([1, 2, 2, 
3, 2, 1, 4], 2, 5) -> [1, 5, 5, 3, 5, 1, 4]`              |
+| array_slice(array, index)             | Returns a slice of the array. 
`array_slice([1, 2, 3, 4, 5, 6, 7, 8], 3, 6) -> [3, 4, 5, 6]`                   
                                                           |
 | array_to_string(array, delimeter)     | Converts each element to its text 
representation. `array_to_string([1, 2, 3, 4], ',') -> 1,2,3,4`                 
                                                       |
 | cardinality(array)                    | Returns the total number of elements 
in the array. `cardinality([[1, 2, 3], [4, 5, 6]]) -> 6`                        
                                                    |
 | make_array(value1, [value2 [, ...]])  | Returns an Arrow array using the 
specified input expressions. `make_array(1, 2, 3) -> [1, 2, 3]`                 
                                                        |
-| trim_array(array, n)                  | Removes the last n elements from the 
array.                                                                          
                                                    |
+| trim_array(array, n)                  | Deprecated                           
                                                                                
                                                    |

Review Comment:
   👍 



##########
datafusion/core/tests/sqllogictests/test_files/struct.slt:
##########
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#   http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#############
+## Struct Expressions Tests
+#############
+
+statement ok
+CREATE TABLE values(
+    a INT,
+    b FLOAT,
+    c VARCHAR
+) AS VALUES
+  (1, 1.1, 'a'),
+  (2, 2.2, 'b'),
+  (3, 3.3, 'c')
+;
+
+# struct[i]
+query III
+select struct(1, 3.14, 'h')['c0'], struct(3, 2.55, 'b')['c1'], struct(2, 6.43, 
'a')['c2'];

Review Comment:
   The `c0` is hardcoded and part of the output of the `struct` function:
   
   ```
   ❯ select struct(1,2);
   +---------------------------+
   | struct(Int64(1),Int64(2)) |
   +---------------------------+
   | {c0: 1, c1: 2}            |
   +---------------------------+
   ```



##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -2550,69 +3060,6 @@ mod tests {
         assert_eq!("1-*-3-*-*-6-7-*", result.value(0));
     }
 
-    #[test]

Review Comment:
   Update: the answer is that trim_array was removed 



##########
datafusion/core/tests/sqllogictests/test_files/struct.slt:
##########
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#   http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#############
+## Struct Expressions Tests
+#############
+
+statement ok
+CREATE TABLE values(
+    a INT,
+    b FLOAT,
+    c VARCHAR
+) AS VALUES
+  (1, 1.1, 'a'),
+  (2, 2.2, 'b'),
+  (3, 3.3, 'c')
+;
+
+# struct[i]
+query III
+select struct(1, 3.14, 'h')['c0'], struct(3, 2.55, 'b')['c1'], struct(2, 6.43, 
'a')['c2'];

Review Comment:
   The `c0` is hardcoded and part of the output of the `struct` function:
   
   ```
   ❯ select struct(1,2);
   +---------------------------+
   | struct(Int64(1),Int64(2)) |
   +---------------------------+
   | {c0: 1, c1: 2}            |
   +---------------------------+
   ```



##########
docs/source/user-guide/expressions.md:
##########
@@ -199,10 +200,11 @@ Unlike to some databases the math functions in Datafusion 
works the same way as
 | array_replace(array, from, to)        | Replaces the first occurrence of the 
specified element with another specified element. `array_replace([1, 2, 2, 3, 
2, 1, 4], 2, 5) -> [1, 5, 2, 3, 2, 1, 4]`             |
 | array_replace_n(array, from, to, max) | Replaces the first `max` occurrences 
of the specified element with another specified element. `array_replace_n([1, 
2, 2, 3, 2, 1, 4], 2, 5, 2) -> [1, 5, 5, 3, 2, 1, 4]` |
 | array_replace_all(array, from, to)    | Replaces all occurrences of the 
specified element with another specified element. `array_replace_all([1, 2, 2, 
3, 2, 1, 4], 2, 5) -> [1, 5, 5, 3, 5, 1, 4]`              |
+| array_slice(array, index)             | Returns a slice of the array. 
`array_slice([1, 2, 3, 4, 5, 6, 7, 8], 3, 6) -> [3, 4, 5, 6]`                   
                                                           |
 | array_to_string(array, delimeter)     | Converts each element to its text 
representation. `array_to_string([1, 2, 3, 4], ',') -> 1,2,3,4`                 
                                                       |
 | cardinality(array)                    | Returns the total number of elements 
in the array. `cardinality([[1, 2, 3], [4, 5, 6]]) -> 6`                        
                                                    |
 | make_array(value1, [value2 [, ...]])  | Returns an Arrow array using the 
specified input expressions. `make_array(1, 2, 3) -> [1, 2, 3]`                 
                                                        |
-| trim_array(array, n)                  | Removes the last n elements from the 
array.                                                                          
                                                    |
+| trim_array(array, n)                  | Deprecated                           
                                                                                
                                                    |

Review Comment:
   👍 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to