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

change the input_type parameter of the create_udaf function from DataType to Vec<DataType> #7096

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

jiangzhx
Copy link
Contributor

Which issue does this PR close?

Closes #7094 .

Rationale for this change

For someone who is new to DataFusion and is trying to write a custom UDAF, it may be a little confusing to understand why create_udaf only takes one DataType for the input_type. Additionally, I did not find any examples demonstrating how to create a UDAF with multiple input arguments.

What changes are included in this PR?

change input_type: DataType to input_type: Vec<DataType>

pub fn create_udaf(
    name: &str,
    return_type: Arc<DataType>,
    volatility: Volatility,
    accumulator: AccumulatorFactoryFunction,
    state_type: Arc<Vec<DataType>>,
) -> AggregateUDF {

Are these changes tested?

Yes

Are there any user-facing changes?

yes

@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules core Core DataFusion crate labels Jul 26, 2023
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jiangzhx

@@ -811,7 +811,7 @@ pub fn create_udaf(
let state_type: StateTypeFunction = Arc::new(move |_| Ok(state_type.clone()));
AggregateUDF::new(
name,
&Signature::exact(vec![input_type], volatility),
&Signature::exact(input_type, volatility),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 makes sense to me

@alamb alamb added the api change Changes the API exposed to users of the crate label Jul 26, 2023
@alamb alamb merged commit 581778d into apache:main Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change Changes the API exposed to users of the crate core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

change the input_type parameter of the create_udaf function from DataType to Vec<DataType>
2 participants