Skip to content

Substrait: Support Expr::ScalarFunction#6471

Merged
alamb merged 5 commits intoapache:mainfrom
jayzhan211:subtrait-scalarfunction
May 30, 2023
Merged

Substrait: Support Expr::ScalarFunction#6471
alamb merged 5 commits intoapache:mainfrom
jayzhan211:subtrait-scalarfunction

Conversation

@jayzhan211
Copy link
Copy Markdown
Contributor

@jayzhan211 jayzhan211 commented May 28, 2023

Which issue does this PR close?

Closes #6411.

Rationale for this change

What changes are included in this PR?

Currently, we had supported Subtrait::ScalarFunction to DF::BinaryExpr when args len is 2. Now, we support Subtrait::ScalarFunction to DF::ScalarFunction for arbitrary args len. Use name to determine Operator or ScalarFunction to transform for two args cases.

Are these changes tested?

Test roundtrip_logical_plan

Are there any user-facing changes?

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@github-actions github-actions Bot added the substrait Changes to the substrait crate label May 28, 2023
@jayzhan211 jayzhan211 marked this pull request as draft May 28, 2023 06:10
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@jayzhan211 jayzhan211 marked this pull request as ready for review May 28, 2023 07:04
Copy link
Copy Markdown
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 @jayzhan211

cc @waynexia

}

fn name_to_scalar_function(name: &str) -> Result<BuiltinScalarFunction> {
match name {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if you can use FromStr for this: https://github.com/apache/arrow-datafusion/blob/2bbc5063fefcc51ca98300e74b1bbc19ef4827ad/datafusion/expr/src/built_in_function.rs#L445-L458

So like

let func = BuiltinScalarFunction::from_str(name)?;

Or perhaps you need a different list of names to match what is in substrait 🤔

@alamb
Copy link
Copy Markdown
Contributor

alamb commented May 28, 2023

cc @nseekhao

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@jayzhan211
Copy link
Copy Markdown
Contributor Author

Thanks for your review, code is updated and ready for review.

@waynexia waynexia self-requested a review May 29, 2023 09:07
Copy link
Copy Markdown
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

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

Generally LGTM, thanks 👍

We can also extend scalar UDF in ScalarFunctionType later

@nseekhao
Copy link
Copy Markdown
Contributor

LGTM. Thank you so much, @jayzhan211 !

@alamb alamb merged commit fd9bdad into apache:main May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Substrait: Expr::ScalarFunction support

4 participants