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

stride arg of array_slice() should be optional #10740

Closed
yutannihilation opened this issue May 31, 2024 · 2 comments
Closed

stride arg of array_slice() should be optional #10740

yutannihilation opened this issue May 31, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@yutannihilation
Copy link

Describe the bug

Currently, all args of array_slice() is mandatory, but stride seems optional.

https://docs.rs/datafusion/38.0.0/datafusion/functions_array/expr_fn/fn.array_slice.html:

pub fn array_slice(array: Expr, begin: Expr, end: Expr, stride: Expr) -> Expr

code:

let args_len = args.len();
if args_len != 3 && args_len != 4 {
return exec_err!("array_slice needs three or four arguments");
}
let stride = if args_len == 4 {
Some(as_int64_array(&args[3])?)
} else {
None
};

To Reproduce

n/a

Expected behavior

n/a

Additional context

n/a

@yutannihilation yutannihilation added the bug Something isn't working label May 31, 2024
@jonahgao
Copy link
Member

Hi @yutannihilation , this has been fixed on the main branch.

#[doc = "returns a slice of the array."]
pub fn array_slice(array: Expr, begin: Expr, end: Expr, stride: Option<Expr>) -> Expr {
let args = match stride {
Some(stride) => vec![array, begin, end, stride],
None => vec![array, begin, end],
};
array_slice_udf().call(args)
}

@yutannihilation
Copy link
Author

Oh, great! Sorry that I didn't look at the latest code. I'm closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants