-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Adding support of map_top_n_values to Presto #18607
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
Conversation
|
See my comments in the other one - MAP_TOP_N_KEYS - same applies here - just do it as a SQL udf |
50669cd to
be3de66
Compare
Cool! Let me do this a SQL UDFs |
7ab8e9c to
8330da3
Compare
presto-main/src/main/java/com/facebook/presto/operator/scalar/sql/MapSqlFunctions.java
Outdated
Show resolved
Hide resolved
8330da3 to
8c5bdaa
Compare
|
Also squash the commits |
|
Same comment as the other PR..... The release note is too verbose. We only need one (long) line to explain what it does in English. Also, we need |
highker
left a comment
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.
Please squash the commits
4ed5a4b to
8c0c365
Compare
185df62 to
325a872
Compare
Done! |
|
Can we merge this PR? |
Add an UDF for getting top N values of a map, which returns an array of the top N values of map. Optionally a lambda comparator can also be passed to perform a custom comparison of the values. Returns all the value if the value N is greater than or equal to size of the map. N must be >= 0. For N = 0, the function returns empty array.
map_top_n_values(map(K, V), N) -> array(V)
map_top_n_values(map(K, V), N, function(V, V, int)) -> array(V)
Return the top N values of the map sorted using the lambda comparator.
Test plan - (Please fill in how you tested your changes)
Added unit tests.
Build successfully using the following terminal command
./mvnw clean install -Dtest=TestMapTopValuesFunction -fn -pl presto-main./mvnw clean install -Dtest=TestMapTopValuesComparatorFunction -fn -pl presto-main