-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add contains_sequence function #5593
Conversation
presto-main/src/main/java/io/prestosql/operator/scalar/ArrayContainsSubarray.java
Outdated
Show resolved
Hide resolved
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.
If this is just contains all, I'm not sure we need a new function, as match_all
covers this. If the goal is contains sub-sequence, then the algorithm will need changes.
presto-main/src/main/java/io/prestosql/operator/scalar/ArrayContainsSubarray.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/operator/scalar/ArrayContainsSubarray.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/operator/scalar/ArrayContainsSubarray.java
Outdated
Show resolved
Hide resolved
presto-main/src/test/java/io/prestosql/operator/scalar/TestArrayContainsSubarray.java
Outdated
Show resolved
Hide resolved
I find the name |
Seems reasonable, how do you think? @dain |
Oh ya, I forgot to mention, we'll need documentation in this file: https://github.com/prestosql/presto/blob/master/presto-docs/src/main/sphinx/functions/array.rst |
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.
Couple of minor things, but otherwise looks good. We'll still want to change to contains_sequence
, and the documentation. Also, please squash this to a single commit, and update the commit message to reflect the new function name.
presto-main/src/main/java/io/prestosql/operator/scalar/ArrayContainsSubarray.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/operator/scalar/ArrayContainsSubarray.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/operator/scalar/ArrayContainsSubarray.java
Outdated
Show resolved
Hide resolved
c9f2345
to
078cbcf
Compare
078cbcf
to
b28e814
Compare
a9b02a6
to
b28e814
Compare
ping @dain |
Syntax looks good to me |
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.
Two minor changes (one from me and one from @electrum) and this is ready to go.
public void testBasic() | ||
{ | ||
assertFunction("contains_sequence(ARRAY [1,2,3,4,5,6], ARRAY[1,2])", BOOLEAN, true); | ||
assertFunction("contains_sequence(ARRAY [1,2,3,4,5,6], ARRAY[3,4])", BOOLEAN, true); |
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.
Can you add assertFunction("contains_sequence(ARRAY [1,2,3,4,5,6], ARRAY[5,6])", BOOLEAN, true);
and
for (int i =1; i <=6; i++) {
assertFunction("contains_sequence(ARRAY [1,2,3,4,5,6], ARRAY[" + i + "])", BOOLEAN, true);
}
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.
done
c2cc840
to
ccd1075
Compare
@tinkerrrr can you squash your commits... you ended up with an extra commit named "Merge remote-tracking branch 'upstream/master' into contains_subarray" |
fix if array contains NULL Make the function truly contains_subarray change contains_subarray to contains_sequence Add UT
82ef460
to
88a12bc
Compare
@dain Done, I did that to try to resolve CI failure... |
Merged, thanks! |
Add a function determines whether an array contains another, with the values in the exact order.