Skip to main content

Module df_udfs_plugin

Module df_udfs_plugin 

Source
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:

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 via scoped_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 None when the call is not inside a scoped_with_session_plugin_registry scope (e.g., a query against Uni directly with no Session in flight, or a unit test invoking the executor outside the host crate).
maybe_scope_with_principal
Run fut either inside a principal task-local scope or unwrapped, depending on whether a principal was supplied.
register_custom_functions_as_plugin_scalars
Register the legacy CustomFunctionRegistry entries as DataFusion scalar UDFs by mirroring them through the plugin-framework adapter.
register_plugin_scalar_udfs
Register every scalar function in a PluginRegistry as 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’s register_udf is last-write-wins by registered name, so session entries shadow instance entries without any explicit ordering logic.
scoped_with_principal
Run fut inside a scope where current_principal resolves to principal.
scoped_with_session_context
Run fut inside both scoped_with_session_plugin_registry and the principal task-local scope in a single call.
scoped_with_session_plugin_registry
Run fut inside a scope that exposes registry as the current session-local plugin registry. Returns the future’s output.