v.21.6New Feature
Added dictGetChildren and dictGetDescendants Functions with Performance Improvements
Added functionsdictGetChildren(dictionary, key),dictGetDescendants(dictionary, key, level). FunctiondictGetChildrenreturn all children as an array if indexes. It is a inverse transformation fordictGetHierarchy. FunctiondictGetDescendantsreturn all descendants as ifdictGetChildrenwas appliedleveltimes recursively. Zerolevelvalue is equivalent to infinity. Improved performance ofdictGetHierarchy,dictIsInfunctions. Closes #14656. #22096 (Maksim Kita).
Why it matters
These new functions solve the problem of efficiently querying dictionary hierarchies by enabling users to get all direct children or all descendants (up to a specified recursion level) of a given key. This provides an inverse operation todictGetHierarchy, enhancing flexibility and usability of dictionaries in hierarchical data scenarios.How to use it
UsedictGetChildren(dictionary, key) to get an array of all direct children indexes for the specified key. Use dictGetDescendants(dictionary, key, level) to retrieve descendants recursively up to the given level (where zero means unlimited recursion). These functions can be called directly in SQL queries. The improved dictGetHierarchy and dictIsIn functions continue to work as before but with better performance.