-
Notifications
You must be signed in to change notification settings - Fork 1k
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: new UDFs for working with Maps #5536
feat: new UDFs for working with Maps #5536
Conversation
|
||
@UdfDescription( | ||
name = "map_union", | ||
description = "Returns a new map containing the union of all entries from both input maps. " |
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.
What if the maps have the same key with different values? Currently, the latter will be in the result. Maybe point this out in the description
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.
yeah - this is described in the docs file but not here, will add something to call it out here also
public class MapUnion { | ||
|
||
@Udf | ||
public <T> Map<String, T> union(final Map<String, T> input1, final Map<String, T> input2) { |
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.
Add @UdfParameter
just so that it can compile without the -parameters
in the pom file?
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.
makes sense
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.
Thank you @blueedgenick ! LGTM! Maybe just add the @UdfParameter
to the udfs so that they can compile without problems if the -parameter
is missing from the pom file
Thanks @vpapavas ! ok to merge with these changes ? |
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, with a few suggestions.
Jim's doc feedback Co-authored-by: Jim Galasyn <jim.galasyn@confluent.io>
Jim's doc feedback Co-authored-by: Jim Galasyn <jim.galasyn@confluent.io>
Jim's doc feedback Co-authored-by: Jim Galasyn <jim.galasyn@confluent.io>
Can you add the |
Three new UDFs:
map_keys(some_map)
- get array of all keys from a mapmap_values(some_map)
- get array of all values from a mapmap_union(map1, map2)
- add all entries from 2 maps into a new mapThis is an updated version of functions and their tests originally proposed waaaay back in PR #1611 and blocked at that time by limited scope for handling generics in the UDF invocation framework.
Ideally I'd like to also make
map_union
variadic but the invocation framework will choke on that until #5511 is resolved.