You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ran Tao (Jira)" <ji...@apache.org> on 2023/08/13 11:58:00 UTC

[jira] [Comment Edited] (CALCITE-5830) Add ARRAY_INSERT function(enabled in Spark library)

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

Ran Tao edited comment on CALCITE-5830 at 8/13/23 11:57 AM:
------------------------------------------------------------

[~jiajunbernoulli]  ARRAY_INSERT is from spark 3.4.0 it has been covered 2 released versions. i think it's stable. and i get your point. however i think spark is right. because it defines "Index above array size appends the array, or prepends the array if index is negative, with `NULL` elements." 

and spark index begins -1 and 1, so 'z' is -1, the original 'c' should move to the next.
// actual spark result
{code:java}
SELECT array_insert(array('a', 'b', 'c'), -1, 'z');
["a","b","z","c"] {code}


was (Author: lemonjing):
[~jiajunbernoulli]  ARRAY_INSERT is from spark 3.4.0 it has been covered 2 released versions. i think it's stable. and i get your point. however i think spark is right. because it defines "Index above array size appends the array, or prepends the array if index is negative, with `NULL` elements." 

and spark index begins -1 and 1, so 'z' is -1, the original 'c' should move to the next.
// actual spark result
SELECT array_insert(array('a', 'b', 'c'), -1, 'z');
["a","b","z","c"]

> Add ARRAY_INSERT function(enabled in Spark library)
> ---------------------------------------------------
>
>                 Key: CALCITE-5830
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5830
>             Project: Calcite
>          Issue Type: New Feature
>          Components: core
>    Affects Versions: 1.34.0
>            Reporter: Ran Tao
>            Assignee: Ran Tao
>            Priority: Major
>              Labels: pull-request-available
>
> array_insert(x, pos, val) - Places val into index pos of array x. Array indices start at 1, or start from the end if index is negative. Index above array size appends the array, or prepends the array if index is negative, with 'null' elements
> *Examples:*
> > SELECT array_insert(array(1, 2, 3, 4), 5, 5); [1,2,3,4,5]
> > SELECT array_insert(array(5, 3, 2, 1), -3, 4); [5,4,3,2,1] 
> https://spark.apache.org/docs/latest/api/sql/index.html#array_insert



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