Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading