[ 
https://issues.apache.org/jira/browse/CALCITE-5751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jiajun Xie resolved CALCITE-5751.
---------------------------------
    Resolution: Fixed

> Add ARRAY_APPEND, ARRAY_POSITION, ARRAY_REMOVE ARRAY_PREPEND for Spark dialect
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-5751
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5751
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: jackylau
>            Assignee: jackylau
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.35.0
>
>
> h3. 
> [array_append|https://spark.apache.org/docs/latest/api/sql/index.html#array_append]
> array_append(array, element) - Add the element at the end of the array passed 
> as first argument. Type of element should be similar to type of the elements 
> of the array. Null element is also appended into the array. But if the array 
> passed, is NULL output is NULL
> *Examples:*
>  
> {code:java}
> {code}
> *> SELECT array_append(array('b', 'd', 'c', 'a'), 'd');
>  ["b","d","c","a","d"]
> > SELECT array_append(array(1, 2, 3, null), null);
>  [1,2,3,null,null]
> > SELECT array_append(CAST(null as Array<Int>), 2);
>  NULL* 
>  
> array_prepend is not in the docs, but in the code
> https://issues.apache.org/jira/browse/SPARK-41233
> {code:java}
> usage = """ _FUNC_(array, element) - Add the element at the beginning of the 
> array passed as first argument. Type of element should be the same as the 
> type of the elements of the array. Null element is also prepended to the 
> array. But if the array passed is NULL output is NULL """, examples = """ 
> Examples: > SELECT _FUNC_(array('b', 'd', 'c', 'a'), 'd'); 
> ["d","b","d","c","a"] > SELECT _FUNC_(array(1, 2, 3, null), null); 
> [null,1,2,3,null] > SELECT _FUNC_(CAST(null as Array<Int>), 2); NULL
> case class ArrayPrepend(left: Expression, right: Expression) extends 
> RuntimeReplaceable {code}
> h3. 
> [array_position|https://spark.apache.org/docs/latest/api/sql/index.html#array_position]
> array_position(array, element) - Returns the (1-based) index of the first 
> element of the array as long.
> *Examples:*
>  
> {code:java}
> > SELECT array_position(array(3, 2, 1), 1);
>  3 {code}
>  
> h3. 
> [array_remove|https://spark.apache.org/docs/latest/api/sql/index.html#array_remove]
> array_remove(array, element) - Remove all elements that equal to element from 
> array.
> *Examples:*
>  
> {code:java}
> > SELECT array_remove(array(1, 2, 3, null, 3), 3);
>  [1,2,null] {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to