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

feat: allow array_slice to take an optional stride parameter #10469

Merged
merged 5 commits into from
May 13, 2024

Conversation

jonahgao
Copy link
Member

@jonahgao jonahgao commented May 12, 2024

Which issue does this PR close?

Closes #10424.

Rationale for this change

Based on the draft PR #10450, and reuse the existing make_udf_function macro as much as possible.

What changes are included in this PR?

  • Allow array_slice to take an optional stride parameter

Are these changes tested?

Not sure whether it's necessary to write a test for this.

Are there any user-facing changes?

Yes

@@ -106,4 +105,26 @@ macro_rules! make_udf_function {
}
}
};
// This pattern does not generate the "fluent expr_fn" style function, it should be provided externally.
($UDF:ty, $SCALAR_UDF_FN:ident) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Applied. This eliminates some duplication of macro codes. Thank you @jayzhan211 .

@@ -581,7 +581,7 @@ async fn roundtrip_expr_api() -> Result<()> {
make_array(vec![lit(1), lit(2), lit(3)]),
lit(1),
lit(2),
lit(1),
Some(lit(1)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add the example that has None for stride?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added.

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.

👍

@alamb alamb added the api change Changes the API exposed to users of the crate label May 13, 2024
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.

LGTM -- thank you @jonahgao and @jayzhan211

@jayzhan211 jayzhan211 merged commit 18fc376 into apache:main May 13, 2024
23 checks passed
@jonahgao jonahgao deleted the array_slice_args branch May 13, 2024 23:49
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
…e#10469)

* feat: allow array_slice to take an optional stride parameter

* Use ScalarUDF::call

* Use create_function and add test

* format

* fix cargo doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change Changes the API exposed to users of the crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stride is not optional for new array_slice UDF
3 participants