Expand description
Plugin-registry scalar-UDF integration for DataFusion.
This module bridges the uni-plugin plugin system into DataFusion’s
scalar-UDF surface. It lives in uni-query (not the dependency-light
uni-query-functions leaf crate) because it depends on uni-plugin
and tokio task-locals.
Responsibilities:
- The
SESSION_PLUGIN_REGISTRYtokio task-local and its scope/read helpers (scoped_with_session_plugin_registry,current_session_plugin_registry). - Re-export of the principal task-local helpers from
uni_plugin::host::principalso callers keep their existinguni_query::scoped_with_principal/current_principalpaths. scoped_with_session_contextcombining both scopes.register_plugin_scalar_udfs/register_plugin_scalar_udfs_pairand thePluginScalarUdfDataFusion adapter (private).
Statics§
- CURRENT_
PRINCIPAL - Tokio task-local carrying the authenticated principal for the in-flight query.
- SESSION_
PLUGIN_ REGISTRY - Tokio task-local carrying the current
Session’s session-local plugin registry across the per-query executor scope. Set by host-crate session execute paths viascoped_with_session_plugin_registry; read at the UDF registration site (register_plugin_scalar_udfs_pair) and at the procedure / Locy-aggregate dual-consult helpers.
Functions§
- current_
principal - Borrow the principal active for the current execute scope, if any.
- current_
session_ plugin_ registry - Borrow the current session-local plugin registry, if any. Returns
Nonewhen the call is not inside ascoped_with_session_plugin_registryscope (e.g., a query againstUnidirectly with no Session in flight, or a unit test invoking the executor outside the host crate). - maybe_
scope_ with_ principal - Run
futeither inside a principal task-local scope or unwrapped, depending on whether a principal was supplied. - register_
custom_ functions_ as_ plugin_ scalars - Register the legacy
CustomFunctionRegistryentries as DataFusion scalar UDFs by mirroring them through the plugin-framework adapter. - register_
plugin_ scalar_ udfs - Register every scalar function in a
PluginRegistryas a DataFusion UDF. - register_
plugin_ scalar_ udfs_ pair - Two-registry variant of
register_plugin_scalar_udfs— registers the instance registry’s scalars first, then the session registry’s (if present) on top. DataFusion’sregister_udfis last-write-wins by registered name, so session entries shadow instance entries without any explicit ordering logic. - scoped_
with_ principal - Run
futinside a scope wherecurrent_principalresolves toprincipal. - scoped_
with_ session_ context - Run
futinside bothscoped_with_session_plugin_registryand the principal task-local scope in a single call. - scoped_
with_ session_ plugin_ registry - Run
futinside a scope that exposesregistryas the current session-local plugin registry. Returns the future’s output.