v.21.4New Features

Added dictGetOrNull function to return Null for missing keys

Added function dictGetOrNull. It works like dictGet, but return Null in case key was not found in dictionary. Closes #22375. #22413 (Maksim Kita).
Introduced the dictGetOrNull function, which retrieves values from dictionaries and returns Null if the key is not found, instead of raising an error.

Why it matters

This function addresses the limitation of dictGet that throws an exception when a key is missing in the dictionary, enabling queries to continue smoothly and handle missing keys gracefully by returning Null.

How to use it

Replace dictGet with dictGetOrNull in your queries where dictionary keys might be missing to avoid exceptions. Usage syntax is similar to dictGet, for example:

SELECT dictGetOrNull('dictionary_name', 'attribute_name', toUInt64(key))
FROM table