Repository navigation
Add dictGetRoot function for hierarchical dictionaries - #109459
Merged
Merged
Conversation
`dictGetRoot(dict_name, key)` returns the topmost ancestor (the root) of a key in a hierarchical dictionary. It is a convenient equivalent of taking the last element of `dictGetHierarchy`, i.e. `dictGetHierarchy(dict_name, key)[-1]`. If the key is itself a top-level node of the hierarchy, the key is returned. If the key is absent from the dictionary, `0` is returned, matching the behavior of `dictGetHierarchy(dict_name, key)[-1]` (an absent key produces an empty hierarchy). The function reuses the existing per-dictionary `getHierarchy` implementation, so it works for all layouts that support hierarchy (flat, hashed, hashed_array, cache, direct) without any per-dictionary code. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
Contributor
|
Workflow [PR], commit [3cc7da1] Summary: ✅
AI ReviewSummaryThis PR adds Final Verdict
|
The equivalence query used `min(...) FROM system.numbers LIMIT 6`, but `LIMIT` does not push down through the aggregation, so `min` read all of `system.numbers` and hit `max_rows_to_read`, failing with `TOO_MANY_ROWS` in the Fast test. Use `numbers(6)` to bound the read to the intended 6 rows. The output is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The regression test only proved the `dictGetHierarchy(dict, key)[-1]` equivalence for the non-nullable `UInt64` hierarchy, where the root's parent is the `0` sentinel. A `Nullable(UInt64) HIERARCHICAL` dictionary stops the hierarchy at a `NULL` parent instead, so `0` can be a genuine node rather than the null value. Add a second block that builds a nullable-parent hierarchy across all five layouts (flat, hashed, hashed_array, cache, direct) and checks the same `dictGetRoot` equivalence. It also documents that key `0` (a real root) and an absent key both return the default `0` and are indistinguishable, exactly as for `dictGetHierarchy(dict, key)[-1]`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 task
The dictGetRoot function is authorized by the dictGet privilege: it reuses FunctionDictHelper, which calls checkAccess(AccessType::dictGet, ...), and functionIsDictGet matches the dictGet name prefix. Add dictGetRoot next to its sibling dictGetHierarchy in the dictGet alias list so that GRANT dictGetRoot works as an alias, SHOW PRIVILEGES advertises it, and the grant documentation lists it. Refresh 01271_show_privileges.reference accordingly. Addresses the AI review feedback on the PR. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Jul 12, 2026
…tGet privilege functionIsDictGet (src/Interpreters/misc.h) gates every dictGet* function, including dictGetChildren and dictGetDescendants, behind AccessType::dictGet. The alias list added for dictGetRoot omitted these two siblings, so SHOW PRIVILEGES and grant.md still didn't reflect that GRANT dictGetChildren and GRANT dictGetDescendants work as exact aliases of dictGet.
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 67/72 (93.06%) · Uncovered code |
1 task done
This was referenced Jul 19, 2026
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…blic Add dictGetRoot function for hierarchical dictionaries
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new function
dictGetRoot(dict_name, key)that returns the topmost ancestor (the root) of a key in a hierarchical dictionary.Previously, to get the root of an element you had to take the last element of
dictGetHierarchy, i.e.dictGetHierarchy(dict_name, key)[-1].dictGetRootreturns it directly as a scalar.0is returned (matchingdictGetHierarchy(dict_name, key)[-1], where an absent key produces an empty hierarchy).It reuses the existing per-dictionary
getHierarchyimplementation, so it works for all layouts that support hierarchy (flat,hashed,hashed_array,cache,direct) without any per-dictionary code.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added a new function
dictGetRootwhich returns the topmost ancestor (the root) of a key in a hierarchical dictionary. It is a convenient equivalent ofdictGetHierarchy(dict_name, key)[-1].Documentation entry for user-facing changes
Version info
26.7.1.1175(included in26.7and later)