-
Notifications
You must be signed in to change notification settings - Fork 76
feat: add support for remaining map pipeline expressions
#2321
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
Open
dlarocque
wants to merge
8
commits into
main
Choose a base branch
from
dl/map-expressions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+492
−0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ffdcffb
feat: add support for remaining `map` pipeline expressions
dlarocque d127f8b
remove new constant expr overload
dlarocque 9aa27a0
chore: generate libraries at Mon Feb 23 19:39:31 UTC 2026
cloud-java-bot 4a9ec5b
Merge branch 'main' into dl/map-expressions
dlarocque a407627
Merge branch 'dl/map-expressions' of https://github.com/googleapis/ja…
dlarocque 38a1ff1
pipeline snippets and docs fix
dlarocque dbef287
Merge branch 'main' into dl/map-expressions
dlarocque f24ac13
chore: generate libraries at Fri Feb 27 15:46:31 UTC 2026
cloud-java-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1955,6 +1955,172 @@ public static Expression mapRemove(String mapField, String key) { | |
| return mapRemove(field(mapField), key); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns a new map with the specified entries added or updated. | ||
| * | ||
| * <ul> | ||
| * <li>Only performs shallow updates to the map. | ||
| * <li>Setting a value to {@code null} will retain the key with a {@code null} value. To remove | ||
| * a key entirely, use {@code mapRemove}. | ||
| * </ul> | ||
| * | ||
| * @param mapExpr The expression representing the map. | ||
| * @param key The key to set. Must be an expression representing a string. | ||
| * @param value The value to set. | ||
| * @param moreKeyValues Additional key-value pairs to set. | ||
| * @return A new {@link Expression} representing the map with the entries set. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapSet( | ||
| Expression mapExpr, Expression key, Expression value, Expression... moreKeyValues) { | ||
| ImmutableList.Builder<Expression> builder = ImmutableList.builder(); | ||
| builder.add(mapExpr); | ||
| builder.add(key); | ||
| builder.add(value); | ||
| builder.add(moreKeyValues); | ||
| return new FunctionExpression("map_set", builder.build()); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns a new map with the specified entries added or updated. | ||
| * | ||
| * <ul> | ||
| * <li>Only performs shallow updates to the map. | ||
| * <li>Setting a value to {@code null} will retain the key with a {@code null} value. To remove | ||
| * a key entirely, use {@code mapRemove}. | ||
| * </ul> | ||
| * | ||
| * @param mapExpr The map field to set entries in. | ||
| * @param key The key to set. | ||
| * @param value The value to set. | ||
| * @param moreKeyValues Additional key-value pairs to set. | ||
| * @return A new {@link Expression} representing the map with the entries set. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapSet( | ||
| Expression mapExpr, String key, Object value, Object... moreKeyValues) { | ||
| return mapSet( | ||
| mapExpr, | ||
| constant(key), | ||
| toExprOrConstant(value), | ||
| toArrayOfExprOrConstant(moreKeyValues).toArray(new Expression[0])); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns a new map with the specified entries added or updated. | ||
| * | ||
| * <ul> | ||
| * <li>Only performs shallow updates to the map. | ||
| * <li>Setting a value to {@code null} will retain the key with a {@code null} value. To remove | ||
| * a key entirely, use {@code mapRemove}. | ||
| * </ul> | ||
| * | ||
| * @param mapField The map field to set entries in. | ||
| * @param key The key to set. Must be an expression representing a string. | ||
| * @param value The value to set. | ||
| * @param moreKeyValues Additional key-value pairs to set. | ||
| * @return A new {@link Expression} representing the map with the entries set. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapSet( | ||
| String mapField, Expression key, Expression value, Expression... moreKeyValues) { | ||
| return mapSet(field(mapField), key, value, moreKeyValues); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns a new map with the specified entries added or updated. | ||
| * | ||
| * <ul> | ||
| * <li>Only performs shallow updates to the map. | ||
| * <li>Setting a value to {@code null} will retain the key with a {@code null} value. To remove | ||
| * a key entirely, use {@code mapRemove}. | ||
| * </ul> | ||
| * | ||
| * @param mapField The map field to set entries in. | ||
| * @param key The key to set. Must be an expression representing a string. | ||
| * @param value The value to set. | ||
| * @param moreKeyValues Additional key-value pairs to set. | ||
| * @return A new {@link Expression} representing the map with the entries set. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapSet( | ||
| String mapField, String key, Object value, Object... moreKeyValues) { | ||
| return mapSet(field(mapField), key, value, moreKeyValues); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the keys of a map. | ||
| * | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. u added note for these functions in other sdks |
||
| * @param mapExpr The expression representing the map to get the keys of. | ||
| * @return A new {@link Expression} representing the keys of the map. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapKeys(Expression mapExpr) { | ||
| return new FunctionExpression("map_keys", ImmutableList.of(mapExpr)); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the keys of a map. | ||
| * | ||
| * @param mapField The map field to get the keys of. | ||
| * @return A new {@link Expression} representing the keys of the map. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapKeys(String mapField) { | ||
| return mapKeys(field(mapField)); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the values of a map. | ||
| * | ||
| * <p>While the backend generally preserves insertion order, relying on the order of the output | ||
| * array is not guaranteed and should be avoided. | ||
| * | ||
| * @param mapExpr The expression representing the map to get the values of. | ||
| * @return A new {@link Expression} representing the values of the map. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapValues(Expression mapExpr) { | ||
| return new FunctionExpression("map_values", ImmutableList.of(mapExpr)); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the values of a map. | ||
| * | ||
| * @param mapField The map field to get the values of. | ||
| * @return A new {@link Expression} representing the values of the map. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapValues(String mapField) { | ||
| return mapValues(field(mapField)); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the entries of a map as an array of maps, where each map | ||
| * contains a "k" property for the key and a "v" property for the value. | ||
| * | ||
| * <p>While the backend generally preserves insertion order, relying on the order of the output | ||
| * array is not guaranteed and should be avoided. | ||
| * | ||
| * @param mapExpr The expression representing the map to get the entries of. | ||
| * @return A new {@link Expression} representing the entries of the map. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapEntries(Expression mapExpr) { | ||
| return new FunctionExpression("map_entries", ImmutableList.of(mapExpr)); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the entries of a map as an array of maps. | ||
| * | ||
| * @param mapField The map field to get the entries of. | ||
| * @return A new {@link Expression} representing the entries of the map. | ||
| */ | ||
| @BetaApi | ||
| public static Expression mapEntries(String mapField) { | ||
| return mapEntries(field(mapField)); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that reverses a string, blob, or array. | ||
| * | ||
|
|
@@ -4376,6 +4542,80 @@ public final Expression mapRemove(String key) { | |
| return mapRemove(this, key); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns a new map with the specified entries added or updated. | ||
| * | ||
| * <p>Note that {@code mapSet} only performs shallow updates to the map. Setting a value to {@code | ||
| * null} will retain the key with a {@code null} value. To remove a key entirely, use {@code | ||
| * mapRemove}. | ||
| * | ||
| * @param key The key to set. | ||
| * @param value The value to set. | ||
| * @param moreKeyValues Additional key-value pairs to set. | ||
| * @return A new {@link Expression} representing the map with the entries set. | ||
| */ | ||
| @BetaApi | ||
| public final Expression mapSet(Expression key, Expression value, Expression... moreKeyValues) { | ||
| return mapSet(this, key, value, moreKeyValues); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns a new map with the specified entries added or updated. | ||
| * | ||
| * @param key The key to set. | ||
| * @param value The value to set. | ||
| * @param moreKeyValues Additional key-value pairs to set. | ||
| * @return A new {@link Expression} representing the map with the entries set. | ||
| */ | ||
| @BetaApi | ||
| public final Expression mapSet(String key, Object value, Object... moreKeyValues) { | ||
| return mapSet( | ||
| this, | ||
| constant(key), | ||
| toExprOrConstant(value), | ||
| toArrayOfExprOrConstant(moreKeyValues).toArray(new Expression[0])); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the keys of this map expression. | ||
| * | ||
| * <p>While the backend generally preserves insertion order, relying on the order of the output | ||
| * array is not guaranteed and should be avoided. | ||
| * | ||
| * @return A new {@link Expression} representing the keys of the map. | ||
| */ | ||
| @BetaApi | ||
| public final Expression mapKeys() { | ||
| return mapKeys(this); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the values of this map expression. | ||
| * | ||
| * <p>While the backend generally preserves insertion order, relying on the order of the output | ||
| * array is not guaranteed and should be avoided. | ||
| * | ||
| * @return A new {@link Expression} representing the values of the map. | ||
| */ | ||
| @BetaApi | ||
| public final Expression mapValues() { | ||
| return mapValues(this); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that returns the entries of this map expression as an array of maps, | ||
| * where each map contains a "k" property for the key and a "v" property for the value. | ||
| * | ||
| * <p>While the backend generally preserves insertion order, relying on the order of the output | ||
| * array is not guaranteed and should be avoided. | ||
| * | ||
| * @return A new {@link Expression} representing the entries of the map. | ||
| */ | ||
| @BetaApi | ||
| public final Expression mapEntries() { | ||
| return mapEntries(this); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an expression that reverses this expression, which must be a string, blob, or array. | ||
| * | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why use list?