polars_sql/
function_registry.rs1use polars_error::{PolarsResult, polars_bail};
4use polars_plan::prelude::udf::UserDefinedFunction;
5pub use polars_plan::prelude::{Context, FunctionOptions};
6pub trait FunctionRegistry: Send + Sync {
8 fn register(&mut self, name: &str, fun: UserDefinedFunction) -> PolarsResult<()>;
10 fn get_udf(&self, name: &str) -> PolarsResult<Option<UserDefinedFunction>>;
12 fn contains(&self, name: &str) -> bool;
14}
15
16pub struct DefaultFunctionRegistry {}
18
19impl FunctionRegistry for DefaultFunctionRegistry {
20 fn register(&mut self, _name: &str, _fun: UserDefinedFunction) -> PolarsResult<()> {
21 polars_bail!(ComputeError: "'register' not implemented on DefaultFunctionRegistry'")
22 }
23
24 fn get_udf(&self, _name: &str) -> PolarsResult<Option<UserDefinedFunction>> {
25 polars_bail!(ComputeError: "'get_udf' not implemented on DefaultFunctionRegistry'")
26 }
27 fn contains(&self, _name: &str) -> bool {
28 false
29 }
30}