Skip to content

Apache DataFusion SQL Query Engine

feat: pass SessionState not SessionConfig to FunctionFactory::create (#9837)

Trent Hauck6f9948b8c027
diff --git a/datafusion-examples/examples/function_factory.rs b/datafusion-examples/examples/function_factory.rs
index 6c033e6c8e..a7c8558c6d 100644
--- a/datafusion-examples/examples/function_factory.rs
+++ b/datafusion-examples/examples/function_factory.rs
@@ -16,8 +16,9 @@
// under the License.
use datafusion::error::Result;
-use datafusion::execution::config::SessionConfig;
-use datafusion::execution::context::{FunctionFactory, RegisterFunction, SessionContext};
+use datafusion::execution::context::{
+ FunctionFactory, RegisterFunction, SessionContext, SessionState,
+};
use datafusion_common::tree_node::{Transformed, TreeNode};
use datafusion_common::{exec_err, internal_err, DataFusionError};
use datafusion_expr::simplify::ExprSimplifyResult;
@@ -91,7 +92,7 @@ impl FunctionFactory for CustomFunctionFactory {
/// the function instance.
async fn create(
&self,
- _state: &SessionConfig,
+ _state: &SessionState,
statement: CreateFunction,
) -> Result<RegisterFunction> {
let f: ScalarFunctionWrapper = statement.try_into()?;
diff --git a/datafusion/core/src/execution/context/mod.rs b/datafusion/core/src/execution/context/mod.rs
index 116e45c8c1..31f390607f 100644
--- a/datafusion/core/src/execution/context/mod.rs
+++ b/datafusion/core/src/execution/context/mod.rs
@@ -794,7 +794,7 @@ impl SessionContext {
let function_factory = &state.function_factory;
match function_factory {
- Some(f) => f.create(state.config(), stmt).await?,
+ Some(f) => f.create(&state, stmt).await?,
_ => Err(DataFusionError::Configuration(
"Function factory has not been configured".into(),
))?,
@@ -1288,7 +1288,7 @@ pub trait FunctionFactory: Sync + Send {
/// Handles creation of user defined function specified in [CreateFunction] statement
async fn create(
&self,
- state: &SessionConfig,
+ state: &SessionState,
statement: CreateFunction,
) -> Result<RegisterFunction>;
}
diff --git a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs
index b525e4fc63..86be887198 100644
--- a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs
+++ b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs
@@ -747,7 +747,7 @@ struct CustomFunctionFactory {}
impl FunctionFactory for CustomFunctionFactory {
async fn create(
&self,
- _state: &SessionConfig,
+ _state: &SessionState,
statement: CreateFunction,
) -> Result<RegisterFunction> {
let f: ScalarFunctionWrapper = statement.try_into()?;