You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Gengliang Wang (Jira)" <ji...@apache.org> on 2022/08/16 23:21:00 UTC

[jira] [Created] (SPARK-40109) New SQL function: get()

Gengliang Wang created SPARK-40109:
--------------------------------------

             Summary: New SQL function: get()
                 Key: SPARK-40109
                 URL: https://issues.apache.org/jira/browse/SPARK-40109
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 3.4.0
            Reporter: Gengliang Wang
            Assignee: Gengliang Wang


Currently, when accessing array element with invalid index under ANSI SQL mode, the error is like:
{quote}[INVALID_ARRAY_INDEX] The index -1 is out of bounds. The array has 3 elements. Use `try_element_at` and increase the array index by 1(the starting array index is 1 for `try_element_at`) to tolerate accessing element at invalid index and return NULL instead. If necessary set "spark.sql.ansi.enabled" to "false" to bypass this error.
{quote}
The provided solution is complicated. I suggest introducing a new method get() which always returns null on an invalid array index. This is from [https://docs.snowflake.com/en/sql-reference/functions/get.html.]

Since Spark's map access always returns null, let's don't support map type in the get method for now.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org