This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 6f9948b8c0 feat: pass SessionState not SessionConfig to
FunctionFactory::create (#9837)
6f9948b8c0 is described below
commit 6f9948b8c027f782431805331de174c4092de40a
Author: Trent Hauck <[email protected]>
AuthorDate: Thu Mar 28 13:40:36 2024 -0700
feat: pass SessionState not SessionConfig to FunctionFactory::create (#9837)
---
datafusion-examples/examples/function_factory.rs | 7 ++++---
datafusion/core/src/execution/context/mod.rs | 4 ++--
.../core/tests/user_defined/user_defined_scalar_functions.rs | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
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()?;