Skip to content

Minor: cleanup datafusion-spark scalar functions #15921

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

Merged
merged 1 commit into from
May 2, 2025

Conversation

alamb
Copy link
Contributor

@alamb alamb commented May 2, 2025

Which issue does this PR close?

Rationale for this change

I was reviewing the macro added in #15917 and thought I could make it slightly simpler

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@alamb alamb marked this pull request as ready for review May 2, 2025 15:00
@alamb alamb requested a review from Copilot May 2, 2025 15:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies the scalar function testing macros in the DataFusion Spark module by cleaning up the handling of argument fields.

  • Explicitly types the owned argument fields for clarity.
  • Refactors the construction and passing of argument field references in the function invocation calls.

@@ -28,7 +28,7 @@ pub mod test {
let expected: datafusion_common::Result<Option<$EXPECTED_TYPE>> = $EXPECTED;
let func = $FUNC;

let arg_fields_owned = $ARGS
let arg_fields_owned: Vec<arrow::datatypes::Field> = $ARGS
Copy link
Preview

Copilot AI May 2, 2025

Choose a reason for hiding this comment

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

[nitpick] If $ARGS already yields a Vecarrow::datatypes::Field, the explicit type annotation might be redundant. Consider removing it or adding a comment to clarify its purpose.

Suggested change
let arg_fields_owned: Vec<arrow::datatypes::Field> = $ARGS
let arg_fields_owned = $ARGS

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@blaginin blaginin left a comment

Choose a reason for hiding this comment

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

🙏

@alamb
Copy link
Contributor Author

alamb commented May 2, 2025

Thank you for the review @blaginin

@alamb alamb merged commit 47518aa into apache:main May 2, 2025
27 checks passed
args: $ARGS,
number_rows: cardinality,
return_field: &return_field,
arg_fields: arg_fields.clone(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in particular the change is to avoid calling collect twice and instead create the vec once and reuse it

@alamb alamb deleted the alamb/cleanup_spark branch May 2, 2025 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants