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

refactor: use ExprBuilder to consume substrait expr and use macro to generate error #8515

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

waynexia
Copy link
Member

@waynexia waynexia commented Dec 12, 2023

Which issue does this PR close?

Related to #8149

Rationale for this change

This PR does two reactors:

  • Merge all Expr branches in ScalarFunctionType into one. And move the dispatch logic into BuiltinExprBuilder.
  • Define and use substrait_err!/substrait_datafusion_err! to generate errors.

I'm going to implement other Expr types in substrait. This refactoring makes it easier to extend the match of Exprs

What changes are included in this PR?

As described above. This PR doesn't contains logical change

Are these changes tested?

By existing cases

Are there any user-facing changes?

No

@@ -517,6 +517,9 @@ make_error!(not_impl_err, not_impl_datafusion_err, NotImplemented);
// Exposes a macro to create `DataFusionError::Execution`
make_error!(exec_err, exec_datafusion_err, Execution);

// Exposes a macro to create `DataFusionError::Substrait`
make_error!(substrait_err, substrait_datafusion_err, Substrait);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


impl BuiltinExprBuilder {
pub fn try_from_name(name: &str) -> Option<Self> {
match name {
Copy link
Contributor

@comphead comphead Dec 12, 2023

Choose a reason for hiding this comment

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

should we that be case insensitive?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the existing code is also case sensitive. Not that we shouldn't fix it if it should be ignoring case, but I dont' think this PR makes it any better or worse

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for reminding me 👍 I added an item to #8149, I would take other implementations as a reference on how they handle case sensitivity.

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.

Looks good to me -- thank you @waynexia and @comphead

cc @nseekhao who I think has worked on this code as well


impl BuiltinExprBuilder {
pub fn try_from_name(name: &str) -> Option<Self> {
match name {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the existing code is also case sensitive. Not that we shouldn't fix it if it should be ignoring case, but I dont' think this PR makes it any better or worse

@waynexia waynexia merged commit cf2de9b into apache:main Dec 14, 2023
23 checks passed
@waynexia waynexia deleted the refactor-substrait-expr branch December 14, 2023 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants