-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: support array_reverse #9023
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation seems good, just a bit unsure on dealing with null/empty arrays 🤔
DataType::List(field) => { | ||
let array = as_list_array(&arg[0])?; | ||
general_array_reverse::<i32>(array, &field) | ||
} | ||
DataType::LargeList(field) => { | ||
let array = as_large_list_array(&arg[0])?; | ||
general_array_reverse::<i64>(array, &field) | ||
} | ||
DataType::Null => Ok(arg[0].clone()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a TODO item/create new issue for support for reversing FixedSizeList too?
Unless you feel you can add in support for that in this PR, even though they aren't a GenericListArray underneath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not handle FixedSizeList
here, which will be solved by type coercion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah makes sense. So this would be done in a later PR, if I understand correctly?
Else if it should already work with FixedSizeList
then can add that as a test case in slt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still working on other pr, so I added a TODO test in slt.
DataType::List(field) => { | ||
let array = as_list_array(&arg[0])?; | ||
general_array_reverse::<i32>(array, &field) | ||
} | ||
DataType::LargeList(field) => { | ||
let array = as_large_list_array(&arg[0])?; | ||
general_array_reverse::<i64>(array, &field) | ||
} | ||
DataType::Null => Ok(arg[0].clone()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah makes sense. So this would be done in a later PR, if I understand correctly?
Else if it should already work with FixedSizeList
then can add that as a test case in slt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
@@ -1609,6 +1614,7 @@ impl BuiltinScalarFunction { | |||
BuiltinScalarFunction::ArrayReplaceAll => { | |||
&["array_replace_all", "list_replace_all"] | |||
} | |||
BuiltinScalarFunction::ArrayReverse => &["array_reverse", "list_reverse"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clickhouse support reverse(arr)
, I think we can have it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But reverse
exists for Reverses the order of the characters in the string.
https://arrow.apache.org/datafusion/user-guide/sql/scalar_functions.html#reverse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't notice that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Weijun-H -- this looks good to me. Thank you 🙏
Can you please merge up and resolve conflicts and I think this PR will be ready to go
f33c430
to
f69c29e
Compare
Thanks again @Weijun-H @jayzhan211 and @Jefffrey |
Which issue does this PR close?
Closes #9021
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?