TRY_ELEMENT_AT
Overview
Retrieves a value from an ARRAY or MAP by index or key. Returns NULL instead of throwing an error when the index is out of bounds or the key does not exist. Difference from ELEMENT_AT: ELEMENT_AT throws an error on out-of-bounds access; TRY_ELEMENT_AT returns NULL.
Syntax
Parameters
<array>: ARRAY type. Uses 1-based positive integer indexing;-1refers to the last element.<map>: MAP type. Uses a key to access the corresponding value.<index>: BIGINT type. 1-based index; negative values are supported (-1is the last element).<key>: Must match the MAP key type.
Examples
Related Documentation
- ELEMENT_AT — version that throws an error on out-of-bounds access
