v.24.10New Feature

New Function arrayElementOrNull Returns NULL for Out of Range Indexes and Missing Map Keys

A new function arrayElementOrNull. It returns NULL if the array index is out of range or a Map key not found. #69646 (李扬).
Introduces a new function arrayElementOrNull that returns NULL when the array index is out of range or a Map key is not found.

Why it matters

This feature addresses the need for safer element access in arrays and Maps by returning NULL instead of throwing an error or exception when the specified index or key does not exist. It helps prevent query failures and simplifies null handling in user queries.

How to use it

Use the function arrayElementOrNull(array, index) for arrays or arrayElementOrNull(map, key) for Maps in your SQL queries. It will return the element at the given position or key, or NULL if the index/key is out of range or missing.