[ 
https://issues.apache.org/jira/browse/DRILL-6963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16747905#comment-16747905
 ] 

benj commented on DRILL-6963:
-----------------------------

Sure, for example, PostgreSQL has these kind of functionality
 * Work with array : [https://www.postgresql.org/docs/11/arrays.html]
 * Aggregate in array => array_agg(exp) : 
[https://www.postgresql.org/docs/11/functions-aggregate.html]
 * Some array function and operators : 
[https://www.postgresql.org/docs/9.1/functions-array.html]
 * Some other functions like :
 ** {{regexp_split_to_array}}(text, pattern, flags) : 
[https://www.postgresql.org/docs/current/functions-string.html]

array_agg() is useful, particularly when you group by an item and would like to 
keep some information from another that has variable length / number of line 
concerned in the original table is different for each group.

Example :
{code:java}
With table records
alice;1
alice;2
bob;1
bob;2
bob;3
charles;5

SELECT firstname, array_agg(DISTINCT score ORDER BY score) AS dist_scores
FROM records
GROUP BY firstname;

firstname | dist_score
--------- | ----------
alice     | {1,2}
bob       | {1,2,3}
charles   | {5}

{code}
 

 

> create/aggregate/work with array
> --------------------------------
>
>                 Key: DRILL-6963
>                 URL: https://issues.apache.org/jira/browse/DRILL-6963
>             Project: Apache Drill
>          Issue Type: Wish
>          Components: Functions - Drill
>            Reporter: benj
>            Priority: Major
>
> * Add the possibility to build array (like : SELECT array[a1,a2,a3...]) - 
> ideally work with all types
>  * Add a default array_agg (like : SELECT col1, array_agg(col2), 
> array_agg(DISTINCT col2) FROM ... GROUP BY col1) ;  - ideally work with all 
> types
>  * Add function/facilities/operator to work with array



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to