izveigor opened a new issue, #6804:
URL: https://github.com/apache/arrow-datafusion/issues/6804

   ### Is your feature request related to a problem or challenge?
   
   https://github.com/apache/arrow-datafusion/issues/6709
   https://github.com/apache/arrow-datafusion/issues/6693
   
   ### Describe the solution you'd like
   
   The behavior of columns with array functions should be identical with:
   ### tables
   ```
   postgres=# select * from arr;
       column1     |     column2      |   column3   
   ----------------+------------------+-------------
    {{1,2},{3,4}}  | {1.1,2.2,3.3}    | {L,o,r,e,m}
    {{3,4},{5,6}}  | {4.4,5.5,6.6}    | {i,p,s,u,m}
    {{5,6},{7,8}}  | {7.7,8.8,9.9}    | {d,o,l,o,r}
    {{7,8},{9,10}} | {10.1,11.1,12.2} | {s,i,t}
   (4 rows)
   ```
   
   ```
   postgres=# select * from values;
    a | b | c |  d  |   e   
   ---+---+---+-----+-------
    1 | 1 | 2 | 1.1 | Lorem
    2 | 3 | 4 | 2.2 | ipsum
    3 | 5 | 6 | 3.3 | dolor
    4 | 7 | 8 | 4.4 | sit
   (4 rows)
   ```
   
   ```
   postgres=# select * from arrays_values;
                column1             | column2 | column3 | column4 
   ---------------------------------+---------+---------+---------
    {1,2,3,4,5,6,7,8,9,10}          |       1 |       1 | ,
    {11,12,13,14,15,16,17,18,19,20} |      12 |       2 | .
    {21,22,23,24,25,26,27,28,29,30} |      23 |       3 | -
    {31,32,33,34,35,36,37,38,39,40} |      34 |       4 | ok
   (4 rows)
   ```
   
   ### array_append
   
   ```
   postgres=# select array_append(column1, column2) from arrays_values;
               array_append            
   ------------------------------------
    {1,2,3,4,5,6,7,8,9,10,1}
    {11,12,13,14,15,16,17,18,19,20,12}
    {21,22,23,24,25,26,27,28,29,30,23}
    {31,32,33,34,35,36,37,38,39,40,34}
   (4 rows)
   
   postgres=# select array_append(column2, 100.1), array_append(column3, '.') 
from arr;
         array_append      | array_append  
   ------------------------+---------------
    {1.1,2.2,3.3,100.1}    | {L,o,r,e,m,.}
    {4.4,5.5,6.6,100.1}    | {i,p,s,u,m,.}
    {7.7,8.8,9.9,100.1}    | {d,o,l,o,r,.}
    {10.1,11.1,12.2,100.1} | {s,i,t,.}
   (4 rows)
   ```
   
   ### array_prepend
   
   ```
   postgres=# select array_prepend(column2, column1) from arrays_values;
              array_prepend            
   ------------------------------------
    {1,1,2,3,4,5,6,7,8,9,10}
    {12,11,12,13,14,15,16,17,18,19,20}
    {23,21,22,23,24,25,26,27,28,29,30}
    {34,31,32,33,34,35,36,37,38,39,40}
   (4 rows)
   
   postgres=# select array_prepend(100.1, column2), array_prepend('.', column3) 
from arr;
        array_prepend      | array_prepend 
   ------------------------+---------------
    {100.1,1.1,2.2,3.3}    | {.,L,o,r,e,m}
    {100.1,4.4,5.5,6.6}    | {.,i,p,s,u,m}
    {100.1,7.7,8.8,9.9}    | {.,d,o,l,o,r}
    {100.1,10.1,11.1,12.2} | {.,s,i,t}
   (4 rows)
   ```
   
   ### array_concat
   
   ```
   postgres=# select array_cat(column1, column1), array_cat(column2, column2), 
array_cat(column3, column3) from arr;
             array_cat          |            array_cat            |       
array_cat       
   
-----------------------------+---------------------------------+-----------------------
    {{1,2},{3,4},{1,2},{3,4}}   | {1.1,2.2,3.3,1.1,2.2,3.3}       | 
{L,o,r,e,m,L,o,r,e,m}
    {{3,4},{5,6},{3,4},{5,6}}   | {4.4,5.5,6.6,4.4,5.5,6.6}       | 
{i,p,s,u,m,i,p,s,u,m}
    {{5,6},{7,8},{5,6},{7,8}}   | {7.7,8.8,9.9,7.7,8.8,9.9}       | 
{d,o,l,o,r,d,o,l,o,r}
    {{7,8},{9,10},{7,8},{9,10}} | {10.1,11.1,12.2,10.1,11.1,12.2} | 
{s,i,t,s,i,t}
   (4 rows)
   
   postgres=# select array_cat(column1, array[array[1, 2], array[3, 4]]), 
array_cat(column2, array[1.1, 2.2, 3.3]), array_cat(colum
   n3, array['.', '.', '.']) from arr;
            array_cat          |          array_cat           |     array_cat   
  
   
----------------------------+------------------------------+-------------------
    {{1,2},{3,4},{1,2},{3,4}}  | {1.1,2.2,3.3,1.1,2.2,3.3}    | 
{L,o,r,e,m,.,.,.}
    {{3,4},{5,6},{1,2},{3,4}}  | {4.4,5.5,6.6,1.1,2.2,3.3}    | 
{i,p,s,u,m,.,.,.}
    {{5,6},{7,8},{1,2},{3,4}}  | {7.7,8.8,9.9,1.1,2.2,3.3}    | 
{d,o,l,o,r,.,.,.}
    {{7,8},{9,10},{1,2},{3,4}} | {10.1,11.1,12.2,1.1,2.2,3.3} | {s,i,t,.,.,.}
   (4 rows)
   ```
   
   ### array_position
   
   ```
   postgres=# select array_position(column1, column2), array_position(column1, 
column2, column3) from arrays_values;
    array_position | array_position 
   ----------------+----------------
                 1 |              1
                 2 |              2
                 3 |              3
                 4 |              4
   (4 rows)
   
   postgres=# select array_position(column1, 3), array_position(column1, 3, 5) 
from arrays_values;
    array_position | array_position 
   ----------------+----------------
                 3 |               
                   |               
                   |               
                   |               
   (4 rows)
   ```
   
   ### array_positions
   
   ```
   postgres=# select array_positions(column1, column2) from arrays_values;
    array_positions 
   -----------------
    {1}
    {2}
    {3}
    {4}
   (4 rows)
   
   postgres=# select array_positions(column1, 4), array_positions(array[1, 2, 
23, 13, 33, 45], column2) from arrays_values;
    array_positions | array_positions 
   -----------------+-----------------
    {4}             | {1}
    {}              | {}
    {}              | {3}
    {}              | {}
   (4 rows)
   ```
   
   ### array_replace
   
   ```
   postgres=# select array_replace(column1, column2, column3) from 
arrays_values;
            array_replace          
   --------------------------------
    {1,2,3,4,5,6,7,8,9,10}
    {11,2,13,14,15,16,17,18,19,20}
    {21,22,3,24,25,26,27,28,29,30}
    {31,32,33,4,35,36,37,38,39,40}
   (4 rows)
   
   postgres=# select array_replace(column1, column2, 55), 
array_replace(column1, 22, column3), array_replace(array[1, 2, 3, 4, 5, 6, 7, 
8, 9, 10], column2, column3) from arrays_values;
             array_replace          |          array_replace          |     
array_replace      
   
---------------------------------+---------------------------------+------------------------
    {55,2,3,4,5,6,7,8,9,10}         | {1,2,3,4,5,6,7,8,9,10}          | 
{1,2,3,4,5,6,7,8,9,10}
    {11,55,13,14,15,16,17,18,19,20} | {11,12,13,14,15,16,17,18,19,20} | 
{1,2,3,4,5,6,7,8,9,10}
    {21,22,55,24,25,26,27,28,29,30} | {21,3,23,24,25,26,27,28,29,30}  | 
{1,2,3,4,5,6,7,8,9,10}
    {31,32,33,55,35,36,37,38,39,40} | {31,32,33,34,35,36,37,38,39,40} | 
{1,2,3,4,5,6,7,8,9,10}
   (4 rows)
   ```
   
   ### array_to_string
   
   ```
   postgres=# select array_to_string(column1, column4) from arrays_values;
               array_to_string             
   ----------------------------------------
    1,2,3,4,5,6,7,8,9,10
    11.12.13.14.15.16.17.18.19.20
    21-22-23-24-25-26-27-28-29-30
    31ok32ok33ok34ok35ok36ok37ok38ok39ok40
   (4 rows)
   
   postgres=# select array_to_string(column1, '_') from arrays_values;
           array_to_string        
   -------------------------------
    1_2_3_4_5_6_7_8_9_10
    11_12_13_14_15_16_17_18_19_20
    21_22_23_24_25_26_27_28_29_30
    31_32_33_34_35_36_37_38_39_40
   (4 rows)
   ```
   
   ### cardinality
   
   ```
   postgres=# select cardinality(column1), cardinality(column2), 
cardinality(column3) from arr;
    cardinality | cardinality | cardinality 
   -------------+-------------+-------------
              4 |           3 |           5
              4 |           3 |           5
              4 |           3 |           5
              4 |           3 |           3
   (4 rows)
   ```
   
   ### trim_array
   
   ```
   postgres=# select trim_array(column1, column3) from arrays_values;
           trim_array         
   ---------------------------
    {1,2,3,4,5,6,7,8,9}
    {11,12,13,14,15,16,17,18}
    {21,22,23,24,25,26,27}
    {31,32,33,34,35,36}
   (4 rows)
   
   postgres=# select trim_array(column1, 5), trim_array(array[1, 2, 3, 4, 5, 6, 
7, 8, 9, 10], column3) from arrays_values;
       trim_array    |     trim_array      
   ------------------+---------------------
    {1,2,3,4,5}      | {1,2,3,4,5,6,7,8,9}
    {11,12,13,14,15} | {1,2,3,4,5,6,7,8}
    {21,22,23,24,25} | {1,2,3,4,5,6,7}
    {31,32,33,34,35} | {1,2,3,4,5,6}
   (4 rows)
   ```
   
   ### array_length
   
   ```
   postgres=# select array_length(column1, column3) from arrays_values;
    array_length 
   --------------
              10
                
                
                
   (4 rows)
   
   postgres=# select array_length(array[array[1, 2], array[3, 4]], column3), 
array_length(column1, 1) from arrays_values;
    array_length | array_length 
   --------------+--------------
               2 |           10
               2 |           10
                 |           10
                 |           10
   (4 rows)
   ```
   
   ### array_dims
   
   ```
   postgres=# select array_dims(column1), array_dims(column2), 
array_dims(column3) from arr;
    array_dims | array_dims | array_dims 
   ------------+------------+------------
    [1:2][1:2] | [1:3]      | [1:5]
    [1:2][1:2] | [1:3]      | [1:5]
    [1:2][1:2] | [1:3]      | [1:5]
    [1:2][1:2] | [1:3]      | [1:3]
   (4 rows)
   ```
   
   ### array_ndims
   
   ```
   postgres=# select array_ndims(column1), array_ndims(column2), 
array_ndims(column3) from arr;
    array_ndims | array_ndims | array_ndims 
   -------------+-------------+-------------
              2 |           1 |           1
              2 |           1 |           1
              2 |           1 |           1
              2 |           1 |           1
   (4 rows)
   ```
   
   ### array_contains
   
   ```
   postgres=# select column1 @> column1, column2 @> column2, column3 @> column3 
from arr;
    ?column? | ?column? | ?column? 
   ----------+----------+----------
    t        | t        | t
    t        | t        | t
    t        | t        | t
    t        | t        | t
   (4 rows)
   
   postgres=# select column1 @> array[1, 2], array[5, 6, 7, 8] @> column1 from 
arr;
    ?column? | ?column? 
   ----------+----------
    t        | f
    f        | f
    f        | t
    f        | f
   (4 rows)
   ```
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


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