Skip to content

Move abs to datafusion_functions #9313

New issue

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

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

Already on GitHub? # to your account

Merged
merged 16 commits into from
Feb 27, 2024
Merged

Move abs to datafusion_functions #9313

merged 16 commits into from
Feb 27, 2024

Conversation

yyy1000
Copy link
Contributor

@yyy1000 yyy1000 commented Feb 22, 2024

Which issue does this PR close?

Closes #9286

What changes are included in this PR?

Port logic describe in the issue, also I'm wondering whether I can remove related logic in math_expressions.rs, but I'd like to invest more.

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates labels Feb 22, 2024
// specific language governing permissions and limitations
// under the License.

//! Encoding expressions
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems that it should be something like:

//! Math function: abs()

@github-actions github-actions bot added the substrait Changes to the substrait crate label Feb 22, 2024
// #[tokio::test]
// async fn simple_scalar_function_abs() -> Result<()> {
// roundtrip("SELECT ABS(a) FROM data").await
// }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also @SteveLauC, I think you also may experience this question also. Cause no test case for acos so CI could work now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we may need to fix the issue beforehand to avoid regression on this test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filed #9336

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! @jayzhan211
I applied the changes and this PR should work now.

@@ -160,3 +160,43 @@ macro_rules! downcast_arg {
})?
}};
}

macro_rules! make_abs_function {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need to introduce this new macros? would be that possible to reuse existing macros like it was before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, these are not new macros, but from datafusion-physical_expr like https://github.com/apache/arrow-datafusion/pull/9216/files#r1487960276 said.
I think it's also OK to import and reuse the existing macros, but I think in the future if all functions are moved, macros should also move.🤔

Copy link
Contributor

@jayzhan211 jayzhan211 Feb 25, 2024

Choose a reason for hiding this comment

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

These are macros for abs, I think they should be moved to math.rs. Also, you need to delete those macros in the old file math_expressions.rs

@github-actions github-actions bot removed the substrait Changes to the substrait crate label Feb 26, 2024
Acos = 1;
// 0 was Abs
// The first enum value must be zero for open enums
Acos = 0;
Copy link
Contributor

@jayzhan211 jayzhan211 Feb 26, 2024

Choose a reason for hiding this comment

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

This is not good that old code that has 0 as Abs will accidentally map to Acos, and 1 is missing. I think you can keep it as it is for this PR
After moving them all to UDF, this enum can be deprecated.

I think we need to add unknown = 0 in the future for enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea!
Applied the suggestions now.

Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

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

LGTM Thanks @yyy1000

@jayzhan211 jayzhan211 merged commit 85f7a8e into apache:main Feb 27, 2024
@yyy1000 yyy1000 deleted the port-funs branch February 27, 2024 18:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move abs to datafusion_functions
4 participants