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

Ran Tao edited comment on CALCITE-6285 at 3/1/24 2:57 AM:
----------------------------------------------------------

[~mbudiu] the calcite implementation is compatible/correct with <= spark-3.4.1.

see:

{code:java}
spark-sql (default)> SELECT array_insert(array(5, 3, 2, 1), -4, 4);
[4,5,3,2,1]
{code}

When I implemented it, the latest version was 3.4.1, and now 3.4.2 and 3.5.0 
have fixes.

More background: This function is not Spark's own native function, but is used 
to origin from Snowflake. This function has not been particularly stable. FYI:
https://issues.apache.org/jira/browse/SPARK-45078
https://lists.apache.org/thread/1p5hkql96k5qc5ww6wkd7mq6qdbgyz1n


was (Author: lemonjing):
[~mbudiu] the calcite implementation is compatible/correct with <= spark-3.4.1.

see:

{code:java}
spark-sql (default)> SELECT array_insert(array(5, 3, 2, 1), -4, 4);
[4,5,3,2,1]
{code}

When I implemented it, the latest version was 3.4.1, and now 3.4.2 and 3.5.0 
have fixes.

More background: This function is not Spark's own native function, but is used 
to benchmark Snowflake. This function has not been particularly stable. FYI:
https://issues.apache.org/jira/browse/SPARK-45078
https://lists.apache.org/thread/1p5hkql96k5qc5ww6wkd7mq6qdbgyz1n

> Function ARRAY_INSERT produces an incorrect result for negative indices
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-6285
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6285
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.36.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>
> Here is a test taken from the Spark documentation page: 
> https://spark.apache.org/docs/latest/api/sql/index.html#array_insert
> {code}
> SELECT array_insert(array(5, 3, 2, 1), -4, 4);
> [5,4,3,2,1]
> {code}
> The result produced by Calcite is:
> [4,5,3,2,1]
> The strange thing is that there are tests for negative indices. I wonder if 
> the original tests are wrong, or the behavior of this function in Spark was 
> changed since the tests were written.



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

Reply via email to