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

Draft: Extend Expr::ScalarFunction to support Expr for ScalarUDF #8180

Closed
wants to merge 1 commit into from

Conversation

2010YOUY01
Copy link
Contributor

Which issue does this PR close?

POC for #8157

Rationale for this change

Based on discussion in #8157 , there are two ways to implement Expr creation for ScalarUDF:

  1. Reuse Expr::ScalarUDF
  2. Extend Expr::ScalarFunction

This draft wants to show how approach 2 will look like
pro: This way can encapsulate the execution path for BuitlinScalarFunction and ScalarUDF together (but actually is a slight cleanup instead of unification), which can make future work toward #8045 a little bit easier (when debugging core during migration)
con: Larger modifications to the core code (see comments)

I don't have a strong preference between 1 and 2 for the above reasons, is there any other concerns for approach 1? @alamb

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

Yes, see comments

@github-actions github-actions bot added the logical-expr Logical plan and expressions label Nov 14, 2023
/// ScalarFunction expression
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct ScalarFunction {
/// The function
pub fun: built_in_function::BuiltinScalarFunction,
pub func_def: ScalarFunctionDefinition,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the API change

})?;

fun.return_type(&arg_data_types)
Expr::ScalarFunction(ScalarFunction { func_def, args }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There might have ~10 similar changes like this one during optimization/planning.
Expr::ScalarUDF branch above will be moved inside

@alamb
Copy link
Contributor

alamb commented Nov 15, 2023

This looks pretty neat @2010YOUY01

I don't have a strong preference between 1 and 2 for the above reasons, is there any other concerns for approach 1? @alamb

I am not sure of other concerns -- perhaps it is worth doing a quick prototype / POC, similar to this PR, of what approach 1 would look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants