Description
Currently, when accessing array element with invalid index under ANSI SQL mode, the error is like:
[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.
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.