Enums support #2: provide enums via FunctionNamespaceManagers #14828
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.
This PR follows #14728
Commits start from "provide types from FunctionNamespaceMgr" (seems like we can't do stacked PRs?)
Design
We want plugins to be able to provide enum definitions. However, the current
getTypes
method on thePlugin
interface is not sufficient, because these types are only loaded at server startup time. Instead, if people modify existing enums, or register new ones, we want those to be usable in queries immediately, without the need to reset the cluster.These requirements are similar to those of user-defined SQL functions, which is why it makes sense to expose these types via the FunctionNamespaceManager (FNM) interface. Another argument in favor of doing this is that if users want to register UDFs that use these custom types in their signature, we don't end up with dependencies between different plugins/FNMs: the same FNM can provide the enums and the functions.
Implementation
The gist of the change is in
TypeRegistry::getType
, where we look up a type signature in the available FNMs if it can't be found in our built-in list of types.The rest of the code is refactoring the plumbing to load FNMs inside a TypeRegistry.