Skip to content

Commit

Permalink
feat: pass SessionState not SessionConfig to FunctionFactory::create (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
tshauck authored Mar 28, 2024
1 parent b6915f5 commit 6f9948b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions datafusion-examples/examples/function_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()?;
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/src/execution/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
))?,
Expand Down Expand Up @@ -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>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down

0 comments on commit 6f9948b

Please sign in to comment.