adonis0147 opened a new issue, #9055:
URL: https://github.com/apache/incubator-doris/issues/9055

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### Description
   
   This issue is a sub task of #7570 .
   
   Add aggregation functions for array type:
   1. `array_min`
   2. `array_max`
   3. `array_sum`
   4. `array_avg`
   5. `array_product`
   
   
   ### Use case
   
   ```shell
   mysql> create table array_type_table(k1 INT, k2 Array<int>) duplicate key 
(k1)
       -> distributed by hash(k1) buckets 1 properties('replication_num' = '1');
   mysql> insert into array_type_table values (0, []), (1, [1, 2, 3]);
   mysql> set enable_vectorized_engine = true;    # enable vectorized engine
   mysql> select k2, array_min(k2) from array_type_table;
   +-----------+-----------------+
   | k2        | array_min(`k2`) |
   +-----------+-----------------+
   | []        |               0 |
   | [1, 2, 3] |               1 |
   +-----------+-----------------+
   2 rows in set (0.01 sec)
   
   mysql> select k2, array_max(k2) from array_type_table;
   +-----------+-----------------+
   | k2        | array_max(`k2`) |
   +-----------+-----------------+
   | []        |               0 |
   | [1, 2, 3] |               3 |
   +-----------+-----------------+
   2 rows in set (0.02 sec)
   
   mysql> select k2, array_sum(k2) from array_type_table;
   +-----------+-----------------+
   | k2        | array_sum(`k2`) |
   +-----------+-----------------+
   | []        |               0 |
   | [1, 2, 3] |               6 |
   +-----------+-----------------+
   2 rows in set (0.01 sec)
   
   mysql> select k2, array_avg(k2) from array_type_table;
   +-----------+-----------------+
   | k2        | array_avg(`k2`) |
   +-----------+-----------------+
   | []        |               0 |
   | [1, 2, 3] |               2 |
   +-----------+-----------------+
   2 rows in set (0.01 sec)
   
   mysql> select k2, array_product(k2) from array_type_table;
   +-----------+---------------------+
   | k2        | array_product(`k2`) |
   +-----------+---------------------+
   | []        |                   0 |
   | [1, 2, 3] |                   6 |
   +-----------+---------------------+
   2 rows in set (0.02 sec)
   
   ```
   
   ### Related issues
   
   #7570 
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: commits-unsubscr...@doris.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to