Skip to content

Add support for map_keys_by_top_n_values#21259

Merged
ajaygeorge merged 1 commit intoprestodb:masterfrom
jainavi17:map_top_n_keys_by_value
Nov 29, 2023
Merged

Add support for map_keys_by_top_n_values#21259
ajaygeorge merged 1 commit intoprestodb:masterfrom
jainavi17:map_top_n_keys_by_value

Conversation

@jainavi17
Copy link
Contributor

Description

UDF to return the top N keys of a map by sorting its values in descending order

Motivation and Context

The existing map_top_n_keys provides the top n keys of a map by sorting its keys in the descending order. Based on the feedback received from the Presto Users, we have now added the support of returning top n keys of a map by value.

Test Plan

./mvnw clean install -Dtest=TestMapTopNKeysByValueFunction -Dmaven.javadoc.skip=true -T1C -fn -pl presto-main

== RELEASE NOTES ==

General Changes

  • Add function :func:map_top_n_keys_by_value

    • SELECT map_top_n_keys_by_value(map(ARRAY['a', 'b', 'c'], ARRAY[2, 1, 3]), 2); --- ['c', 'a']

@jainavi17 jainavi17 requested a review from a team as a code owner October 27, 2023 12:47
@jainavi17 jainavi17 requested a review from presto-oss October 27, 2023 12:47
@github-actions
Copy link

github-actions bot commented Oct 27, 2023

Codenotify: Notifying subscribers in CODENOTIFY files for diff 327ca59...84a0814.

Notify File(s)
@steveburnett presto-docs/src/main/sphinx/functions/map.rst

Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

Two small nits requested here. Looks good!

@jainavi17 jainavi17 force-pushed the map_top_n_keys_by_value branch from 66cac33 to eed6dd9 Compare October 28, 2023 19:06
@jainavi17
Copy link
Contributor Author

@steveburnett thanks a ton as always

Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

@jainavi17 jainavi17 requested a review from jaystarshot November 1, 2023 12:50
@jainavi17
Copy link
Contributor Author

@jaystarshot let me know if there are more concerns. Thanks in advance.

@jainavi17 jainavi17 force-pushed the map_top_n_keys_by_value branch 2 times, most recently from 9c84fa7 to 4d5a81b Compare November 16, 2023 19:49
@jainavi17 jainavi17 changed the title Add support for map_top_n_keys_by_value Add support for map_keys_by_top_n_values Nov 16, 2023
@jainavi17 jainavi17 force-pushed the map_top_n_keys_by_value branch from 4d5a81b to 691efda Compare November 16, 2023 20:04
@jainavi17
Copy link
Contributor Author

Hi @jaystarshot , if you could review the PR please.

@kaikalur
Copy link
Contributor

Looking good. Let's merge it

@jainavi17
Copy link
Contributor Author

Can we please merge the PR? cc. @ajaygeorge , @NikhilCollooru

@ajaygeorge
Copy link
Contributor

@jainavi17 one test is failing. Can you please rebase with master and rerun the tests.

UDF to return the top n keys of a map by sorting its values in the descending order
@jainavi17 jainavi17 force-pushed the map_top_n_keys_by_value branch from 691efda to 84a0814 Compare November 29, 2023 11:39
@jainavi17
Copy link
Contributor Author

@ajaygeorge done!

@jainavi17
Copy link
Contributor Author

@NikhilCollooru can we merge the changed please. TIA

@ajaygeorge ajaygeorge merged commit 8d55103 into prestodb:master Nov 29, 2023
@wanglinsong wanglinsong mentioned this pull request Feb 12, 2024
64 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants