From ffdcffb3012bf5f5985852a7650d2f837c40987c Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Fri, 20 Feb 2026 15:56:56 -0500 Subject: [PATCH 1/5] feat: add support for remaining `map` pipeline expressions Adds support for `mapSet`, `mapKeys`, `mapValues`, `mapEntries` pipeline expressions. --- .../pipeline/expressions/Expression.java | 251 ++++++++++++++++++ .../cloud/firestore/it/ITPipelineTest.java | 187 +++++++++++++ .../example/firestore/PipelineSnippets.java | 13 + 3 files changed, 451 insertions(+) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java index 363046c39..fed71314b 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java @@ -178,6 +178,17 @@ public static Expression constant(VectorValue value) { return new Constant(value); } + /** + * Create a constant for an arbitrary value (e.g. Map, List). + * + * @param value The value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(Object value) { + return new Constant(value); + } + /** * Constant for a null value. * @@ -1955,6 +1966,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. + * + * + * + * @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 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. + * + * + * + * @param mapField 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. + * + * + * + * @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. + * + * + * + * @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. + * + * @param mapExpr The map expression 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. + * + *

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. + * + *

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 +4553,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. + * + *

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. + * + *

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. + * + *

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. + * + *

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. * diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 5f810332f..35c60d41c 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -17,6 +17,7 @@ package com.google.cloud.firestore.it; import static com.google.cloud.firestore.FieldValue.vector; +import static com.google.cloud.firestore.LocalFirestoreHelper.query; import static com.google.cloud.firestore.it.ITQueryTest.map; import static com.google.cloud.firestore.it.TestHelper.isRunningAgainstFirestoreEmulator; import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.count; @@ -50,8 +51,12 @@ import static com.google.cloud.firestore.pipeline.expressions.Expression.log; import static com.google.cloud.firestore.pipeline.expressions.Expression.logicalMaximum; import static com.google.cloud.firestore.pipeline.expressions.Expression.logicalMinimum; +import static com.google.cloud.firestore.pipeline.expressions.Expression.mapEntries; +import static com.google.cloud.firestore.pipeline.expressions.Expression.mapKeys; import static com.google.cloud.firestore.pipeline.expressions.Expression.mapMerge; import static com.google.cloud.firestore.pipeline.expressions.Expression.mapRemove; +import static com.google.cloud.firestore.pipeline.expressions.Expression.mapSet; +import static com.google.cloud.firestore.pipeline.expressions.Expression.mapValues; import static com.google.cloud.firestore.pipeline.expressions.Expression.notEqual; import static com.google.cloud.firestore.pipeline.expressions.Expression.nullValue; import static com.google.cloud.firestore.pipeline.expressions.Expression.or; @@ -81,6 +86,7 @@ import com.google.cloud.Timestamp; import com.google.cloud.firestore.Blob; import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentReference; import com.google.cloud.firestore.Firestore; import com.google.cloud.firestore.FirestoreOptions; import com.google.cloud.firestore.GeoPoint; @@ -106,7 +112,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import java.util.Arrays; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; @@ -1376,7 +1384,185 @@ public void testMapGet() throws Exception { map("hugoAward", true, "title", "The Hitchhiker's Guide to the Galaxy"), map("hugoAward", true, "title", "Dune"))); } +@Test + public void testMapSet() throws Exception { + Map docData = new HashMap<>(); + docData.put("existingField", ImmutableMap.of("foo", 1L)); + + Pipeline.Snapshot results = + firestore + .pipeline() + .collection(collection.getPath()) + .replaceWith(Expression.map(docData)) + .limit(1) + .select( + Expression.mapSet("existingField", "bar", 2).as("modifiedField"), + Expression.mapSet(constant(ImmutableMap.of()), "a", 1).as("simple"), + Expression.mapSet(constant(ImmutableMap.of("a", 1)), "b", 2).as("add"), + Expression.mapSet(constant(ImmutableMap.of("a", 1)), "a", 2).as("overwrite"), + Expression.mapSet(constant(ImmutableMap.of("a", 1, "b", 2)), "a", 3, "c", 4).as("multi"), + Expression.mapSet(constant(ImmutableMap.of("a", 1)), "a", field("non_existent")).as("remove"), + Expression.mapSet(constant(ImmutableMap.of("a", 1)), "b", null).as("setNull"), + Expression.mapSet(constant(ImmutableMap.of("a", ImmutableMap.of("b", 1))), "a.b", 2).as("setDotted"), + Expression.mapSet(constant(ImmutableMap.of()), "", "empty").as("setEmptyKey"), + Expression.mapSet(constant(ImmutableMap.of("a", 1)), "b", Expression.add(constant(1), constant(2))).as("setExprVal"), + Expression.mapSet(constant(ImmutableMap.of()), "obj", constant(ImmutableMap.of("hidden", true))).as("setNestedMap"), + Expression.mapSet(constant(ImmutableMap.of()), "~!@#$%^&*()_+", "special").as("setSpecialChars"), + + field("existingField").mapSet("instanceKey", 100).as("instanceSetField"), + constant(ImmutableMap.of("x", 1)).mapSet(constant("y"), constant(2)).as("instanceSetConstant") + ) + .execute() + .get(); + + List resultList = results.getResults(); + assertThat(resultList).isNotEmpty(); + Map data = resultList.get(0).getData(); + + assertThat((Map) data.get("modifiedField")).containsExactly("foo", 1L, "bar", 2L); + assertThat((Map) data.get("simple")).containsExactly("a", 1L); + assertThat((Map) data.get("add")).containsExactly("a", 1L, "b", 2L); + assertThat((Map) data.get("overwrite")).containsExactly("a", 2L); + assertThat((Map) data.get("multi")).containsExactly("a", 3L, "b", 2L, "c", 4L); + assertThat((Map) data.get("remove")).isEmpty(); + assertThat((Map) data.get("setNull")).containsExactly("a", 1L, "b", null); + + Map setDotted = (Map) data.get("setDotted"); + assertThat(setDotted).containsEntry("a.b", 2L); + assertThat((Map) setDotted.get("a")).containsExactly("b", 1L); + + assertThat((Map) data.get("setEmptyKey")).containsExactly("", "empty"); + assertThat((Map) data.get("setExprVal")).containsExactly("a", 1L, "b", 3L); + assertThat((Map) data.get("setNestedMap")).isEqualTo(ImmutableMap.of("obj", ImmutableMap.of("hidden", true))); + assertThat((Map) data.get("setSpecialChars")).containsExactly("~!@#$%^&*()_+", "special"); + + assertThat((Map) data.get("instanceSetField")).containsExactly("foo", 1L, "instanceKey", 100L); + assertThat((Map) data.get("instanceSetConstant")).containsExactly("x", 1L, "y", 2L); + } + @Test + public void testMapKeys() throws Exception { + Map docData = new HashMap<>(); + docData.put("existingField", ImmutableMap.of("foo", 1L)); + + Pipeline.Snapshot results = + firestore + .pipeline() + .collection(collection.getPath()) + .replaceWith(Expression.map(docData)) + .limit(1) + .select( + Expression.mapKeys("existingField").as("existingKeys"), + Expression.mapKeys(constant(ImmutableMap.of("a", 1, "b", 2))).as("keys"), + Expression.mapKeys(constant(ImmutableMap.of())).as("empty_keys"), + Expression.mapKeys(constant(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_keys"), + + field("existingField").mapKeys().as("instanceExistingKeys"), + constant(ImmutableMap.of("x", 10, "y", 20)).mapKeys().as("instanceKeys") + ) + .execute() + .get(); + + List resultList = results.getResults(); + assertThat(resultList).isNotEmpty(); + Map data = resultList.get(0).getData(); + + assertThat((List) data.get("existingKeys")).containsExactly("foo"); + assertThat((List) data.get("keys")).containsExactly("a", "b"); + assertThat((List) data.get("empty_keys")).isEmpty(); + assertThat((List) data.get("nested_keys")).containsExactly("a"); + + assertThat((List) data.get("instanceExistingKeys")).containsExactly("foo"); + assertThat((List) data.get("instanceKeys")).containsExactly("x", "y"); + } + + @Test + public void testMapValues() throws Exception { + Map docData = new HashMap<>(); + docData.put("existingField", ImmutableMap.of("foo", 1L)); + + Pipeline.Snapshot results = + firestore + .pipeline() + .collection(collection.getPath()) + .replaceWith(Expression.map(docData)) + .limit(1) + .select( + Expression.mapValues("existingField").as("existingValues"), + Expression.mapValues(constant(ImmutableMap.of("a", 1, "b", 2))).as("values"), + Expression.mapValues(constant(ImmutableMap.of())).as("empty_values"), + Expression.mapValues(constant(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_values"), + + field("existingField").mapValues().as("instanceExistingValues"), + constant(ImmutableMap.of("x", 10, "y", 20)).mapValues().as("instanceValues") + ) + .execute() + .get(); + + List resultList = results.getResults(); + assertThat(resultList).isNotEmpty(); + Map data = resultList.get(0).getData(); + + assertThat((List) data.get("existingValues")).containsExactly(1L); + assertThat((List) data.get("values")).containsExactly(1L, 2L); + assertThat((List) data.get("empty_values")).isEmpty(); + assertThat((List) data.get("nested_values")).containsExactly(ImmutableMap.of("nested", true)); + + assertThat((List) data.get("instanceExistingValues")).containsExactly(1L); + assertThat((List) data.get("instanceValues")).containsExactly(10L, 20L); + } + + @Test + public void testMapEntries() throws Exception { + Map docData = new HashMap<>(); + docData.put("existingField", ImmutableMap.of("foo", 1L)); + + Pipeline.Snapshot results = + firestore + .pipeline() + .collection(collection.getPath()) + .replaceWith(Expression.map(docData)) + .limit(1) + .select( + Expression.mapEntries("existingField").as("existingEntries"), + Expression.mapEntries(constant(ImmutableMap.of("a", 1, "b", 2))).as("entries"), + Expression.mapEntries(constant(ImmutableMap.of())).as("empty_entries"), + Expression.mapEntries(constant(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_entries"), + + field("existingField").mapEntries().as("instanceExistingEntries"), + constant(ImmutableMap.of("x", 10, "y", 20)).mapEntries().as("instanceEntries") + ) + .execute() + .get(); + + List resultList = results.getResults(); + assertThat(resultList).isNotEmpty(); + Map data = resultList.get(0).getData(); + + assertThat((List) data.get("existingEntries")) + .containsExactly(ImmutableMap.of("k", "foo", "v", 1L)); + + @SuppressWarnings("unchecked") + List> entries = (List>) data.get("entries"); + assertThat(entries).hasSize(2); + + // Map entry order is not guaranteed, so we check containment instead of strict ordering + assertThat(entries).contains(ImmutableMap.of("k", "a", "v", 1L)); + assertThat(entries).contains(ImmutableMap.of("k", "b", "v", 2L)); + + assertThat((List) data.get("empty_entries")).isEmpty(); + assertThat((List) data.get("nested_entries")) + .containsExactly(ImmutableMap.of("k", "a", "v", ImmutableMap.of("nested", true))); + + assertThat((List) data.get("instanceExistingEntries")) + .containsExactly(ImmutableMap.of("k", "foo", "v", 1L)); + + @SuppressWarnings("unchecked") + List> instanceEntries = (List>) data.get("instanceEntries"); + assertThat(instanceEntries).hasSize(2); + assertThat(instanceEntries).contains(ImmutableMap.of("k", "x", "v", 10L)); + assertThat(instanceEntries).contains(ImmutableMap.of("k", "y", "v", 20L)); + } @Test public void testDataManipulationExpressions() throws Exception { List results = @@ -2747,4 +2933,5 @@ public void disallowDuplicateAliasesAcrossStages() { }); assertThat(exception).hasMessageThat().contains("Duplicate alias or field name"); } + } diff --git a/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java b/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java index cf6efe72d..5731a964a 100644 --- a/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java +++ b/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java @@ -1177,6 +1177,19 @@ void mapGetFunction() throws ExecutionException, InterruptedException { System.out.println(result.getResults()); } + void mapSetFunction() throws ExecutionException, InterruptedException { + // [START map_get] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(mapSet(field("awards"), "pulitzer").as("awards")) + .execute() + .get(); + // [END map_get] + System.out.println(result.getResults()); + } + void byteLengthFunction() throws ExecutionException, InterruptedException { // [START byte_length] Pipeline.Snapshot result = From d127f8bbd64db20150b83a56ee3decaf67e4c53c Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Mon, 23 Feb 2026 14:37:09 -0500 Subject: [PATCH 2/5] remove new constant expr overload --- .../pipeline/expressions/Expression.java | 11 ----- .../cloud/firestore/it/ITPipelineTest.java | 48 +++++++++---------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java index fed71314b..d65ec69d6 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java @@ -178,17 +178,6 @@ public static Expression constant(VectorValue value) { return new Constant(value); } - /** - * Create a constant for an arbitrary value (e.g. Map, List). - * - * @param value The value. - * @return A new {@link Expression} constant instance. - */ - @BetaApi - public static Expression constant(Object value) { - return new Constant(value); - } - /** * Constant for a null value. * diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 35c60d41c..c11bfb930 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -1397,20 +1397,20 @@ public void testMapSet() throws Exception { .limit(1) .select( Expression.mapSet("existingField", "bar", 2).as("modifiedField"), - Expression.mapSet(constant(ImmutableMap.of()), "a", 1).as("simple"), - Expression.mapSet(constant(ImmutableMap.of("a", 1)), "b", 2).as("add"), - Expression.mapSet(constant(ImmutableMap.of("a", 1)), "a", 2).as("overwrite"), - Expression.mapSet(constant(ImmutableMap.of("a", 1, "b", 2)), "a", 3, "c", 4).as("multi"), - Expression.mapSet(constant(ImmutableMap.of("a", 1)), "a", field("non_existent")).as("remove"), - Expression.mapSet(constant(ImmutableMap.of("a", 1)), "b", null).as("setNull"), - Expression.mapSet(constant(ImmutableMap.of("a", ImmutableMap.of("b", 1))), "a.b", 2).as("setDotted"), - Expression.mapSet(constant(ImmutableMap.of()), "", "empty").as("setEmptyKey"), - Expression.mapSet(constant(ImmutableMap.of("a", 1)), "b", Expression.add(constant(1), constant(2))).as("setExprVal"), - Expression.mapSet(constant(ImmutableMap.of()), "obj", constant(ImmutableMap.of("hidden", true))).as("setNestedMap"), - Expression.mapSet(constant(ImmutableMap.of()), "~!@#$%^&*()_+", "special").as("setSpecialChars"), + Expression.mapSet(Expression.map(ImmutableMap.of()), "a", 1).as("simple"), + Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "b", 2).as("add"), + Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "a", 2).as("overwrite"), + Expression.mapSet(Expression.map(ImmutableMap.of("a", 1, "b", 2)), "a", 3, "c", 4).as("multi"), + Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "a", field("non_existent")).as("remove"), + Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "b", null).as("setNull"), + Expression.mapSet(Expression.map(ImmutableMap.of("a", ImmutableMap.of("b", 1))), "a.b", 2).as("setDotted"), + Expression.mapSet(Expression.map(ImmutableMap.of()), "", "empty").as("setEmptyKey"), + Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "b", Expression.add(constant(1), constant(2))).as("setExprVal"), + Expression.mapSet(Expression.map(ImmutableMap.of()), "obj", ImmutableMap.of("hidden", true)).as("setNestedMap"), + Expression.mapSet(Expression.map(ImmutableMap.of()), "~!@#$%^&*()_+", "special").as("setSpecialChars"), field("existingField").mapSet("instanceKey", 100).as("instanceSetField"), - constant(ImmutableMap.of("x", 1)).mapSet(constant("y"), constant(2)).as("instanceSetConstant") + Expression.map(ImmutableMap.of("x", 1)).mapSet(constant("y"), constant(2)).as("instanceSetConstant") ) .execute() .get(); @@ -1453,12 +1453,12 @@ public void testMapKeys() throws Exception { .limit(1) .select( Expression.mapKeys("existingField").as("existingKeys"), - Expression.mapKeys(constant(ImmutableMap.of("a", 1, "b", 2))).as("keys"), - Expression.mapKeys(constant(ImmutableMap.of())).as("empty_keys"), - Expression.mapKeys(constant(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_keys"), + Expression.mapKeys(Expression.map(ImmutableMap.of("a", 1, "b", 2))).as("keys"), + Expression.mapKeys(Expression.map(ImmutableMap.of())).as("empty_keys"), + Expression.mapKeys(Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_keys"), field("existingField").mapKeys().as("instanceExistingKeys"), - constant(ImmutableMap.of("x", 10, "y", 20)).mapKeys().as("instanceKeys") + Expression.map(ImmutableMap.of("x", 10, "y", 20)).mapKeys().as("instanceKeys") ) .execute() .get(); @@ -1489,12 +1489,12 @@ public void testMapValues() throws Exception { .limit(1) .select( Expression.mapValues("existingField").as("existingValues"), - Expression.mapValues(constant(ImmutableMap.of("a", 1, "b", 2))).as("values"), - Expression.mapValues(constant(ImmutableMap.of())).as("empty_values"), - Expression.mapValues(constant(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_values"), + Expression.mapValues(Expression.map(ImmutableMap.of("a", 1, "b", 2))).as("values"), + Expression.mapValues(Expression.map(ImmutableMap.of())).as("empty_values"), + Expression.mapValues(Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_values"), field("existingField").mapValues().as("instanceExistingValues"), - constant(ImmutableMap.of("x", 10, "y", 20)).mapValues().as("instanceValues") + Expression.map(ImmutableMap.of("x", 10, "y", 20)).mapValues().as("instanceValues") ) .execute() .get(); @@ -1525,12 +1525,12 @@ public void testMapEntries() throws Exception { .limit(1) .select( Expression.mapEntries("existingField").as("existingEntries"), - Expression.mapEntries(constant(ImmutableMap.of("a", 1, "b", 2))).as("entries"), - Expression.mapEntries(constant(ImmutableMap.of())).as("empty_entries"), - Expression.mapEntries(constant(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_entries"), + Expression.mapEntries(Expression.map(ImmutableMap.of("a", 1, "b", 2))).as("entries"), + Expression.mapEntries(Expression.map(ImmutableMap.of())).as("empty_entries"), + Expression.mapEntries(Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_entries"), field("existingField").mapEntries().as("instanceExistingEntries"), - constant(ImmutableMap.of("x", 10, "y", 20)).mapEntries().as("instanceEntries") + Expression.map(ImmutableMap.of("x", 10, "y", 20)).mapEntries().as("instanceEntries") ) .execute() .get(); From 9aa27a02630ea4521923f9e09a49a275c4fa58a6 Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Mon, 23 Feb 2026 19:41:47 +0000 Subject: [PATCH 3/5] chore: generate libraries at Mon Feb 23 19:39:31 UTC 2026 --- .../pipeline/expressions/Expression.java | 36 ++++---- .../cloud/firestore/it/ITPipelineTest.java | 89 +++++++++++-------- 2 files changed, 69 insertions(+), 56 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java index d65ec69d6..8dfbc1423 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java @@ -1959,9 +1959,9 @@ public static Expression mapRemove(String mapField, String key) { * Creates an expression that returns a new map with the specified entries added or updated. * *

* * @param mapExpr The expression representing the map. @@ -1983,11 +1983,11 @@ public static Expression mapSet( /** * Creates an expression that returns a new map with the specified entries added or updated. - * + * * * * @param mapField The map field to set entries in. @@ -2008,11 +2008,11 @@ public static Expression mapSet( /** * Creates an expression that returns a new map with the specified entries added or updated. - * + * * * * @param mapField The map field to set entries in. @@ -2029,11 +2029,11 @@ public static Expression mapSet( /** * Creates an expression that returns a new map with the specified entries added or updated. - * + * * * * @param mapField The map field to set entries in. @@ -2047,7 +2047,7 @@ 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. * @@ -4603,8 +4603,8 @@ public final Expression mapValues() { } /** - * 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. + * 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. * *

While the backend generally preserves insertion order, relying on the order of the output * array is not guaranteed and should be avoided. diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index c11bfb930..9c445a720 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -17,7 +17,6 @@ package com.google.cloud.firestore.it; import static com.google.cloud.firestore.FieldValue.vector; -import static com.google.cloud.firestore.LocalFirestoreHelper.query; import static com.google.cloud.firestore.it.ITQueryTest.map; import static com.google.cloud.firestore.it.TestHelper.isRunningAgainstFirestoreEmulator; import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.count; @@ -51,12 +50,8 @@ import static com.google.cloud.firestore.pipeline.expressions.Expression.log; import static com.google.cloud.firestore.pipeline.expressions.Expression.logicalMaximum; import static com.google.cloud.firestore.pipeline.expressions.Expression.logicalMinimum; -import static com.google.cloud.firestore.pipeline.expressions.Expression.mapEntries; -import static com.google.cloud.firestore.pipeline.expressions.Expression.mapKeys; import static com.google.cloud.firestore.pipeline.expressions.Expression.mapMerge; import static com.google.cloud.firestore.pipeline.expressions.Expression.mapRemove; -import static com.google.cloud.firestore.pipeline.expressions.Expression.mapSet; -import static com.google.cloud.firestore.pipeline.expressions.Expression.mapValues; import static com.google.cloud.firestore.pipeline.expressions.Expression.notEqual; import static com.google.cloud.firestore.pipeline.expressions.Expression.nullValue; import static com.google.cloud.firestore.pipeline.expressions.Expression.or; @@ -86,7 +81,6 @@ import com.google.cloud.Timestamp; import com.google.cloud.firestore.Blob; import com.google.cloud.firestore.CollectionReference; -import com.google.cloud.firestore.DocumentReference; import com.google.cloud.firestore.Firestore; import com.google.cloud.firestore.FirestoreOptions; import com.google.cloud.firestore.GeoPoint; @@ -112,7 +106,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -1384,7 +1377,8 @@ public void testMapGet() throws Exception { map("hugoAward", true, "title", "The Hitchhiker's Guide to the Galaxy"), map("hugoAward", true, "title", "Dune"))); } -@Test + + @Test public void testMapSet() throws Exception { Map docData = new HashMap<>(); docData.put("existingField", ImmutableMap.of("foo", 1L)); @@ -1400,18 +1394,30 @@ public void testMapSet() throws Exception { Expression.mapSet(Expression.map(ImmutableMap.of()), "a", 1).as("simple"), Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "b", 2).as("add"), Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "a", 2).as("overwrite"), - Expression.mapSet(Expression.map(ImmutableMap.of("a", 1, "b", 2)), "a", 3, "c", 4).as("multi"), - Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "a", field("non_existent")).as("remove"), + Expression.mapSet(Expression.map(ImmutableMap.of("a", 1, "b", 2)), "a", 3, "c", 4) + .as("multi"), + Expression.mapSet( + Expression.map(ImmutableMap.of("a", 1)), "a", field("non_existent")) + .as("remove"), Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "b", null).as("setNull"), - Expression.mapSet(Expression.map(ImmutableMap.of("a", ImmutableMap.of("b", 1))), "a.b", 2).as("setDotted"), + Expression.mapSet( + Expression.map(ImmutableMap.of("a", ImmutableMap.of("b", 1))), "a.b", 2) + .as("setDotted"), Expression.mapSet(Expression.map(ImmutableMap.of()), "", "empty").as("setEmptyKey"), - Expression.mapSet(Expression.map(ImmutableMap.of("a", 1)), "b", Expression.add(constant(1), constant(2))).as("setExprVal"), - Expression.mapSet(Expression.map(ImmutableMap.of()), "obj", ImmutableMap.of("hidden", true)).as("setNestedMap"), - Expression.mapSet(Expression.map(ImmutableMap.of()), "~!@#$%^&*()_+", "special").as("setSpecialChars"), - + Expression.mapSet( + Expression.map(ImmutableMap.of("a", 1)), + "b", + Expression.add(constant(1), constant(2))) + .as("setExprVal"), + Expression.mapSet( + Expression.map(ImmutableMap.of()), "obj", ImmutableMap.of("hidden", true)) + .as("setNestedMap"), + Expression.mapSet(Expression.map(ImmutableMap.of()), "~!@#$%^&*()_+", "special") + .as("setSpecialChars"), field("existingField").mapSet("instanceKey", 100).as("instanceSetField"), - Expression.map(ImmutableMap.of("x", 1)).mapSet(constant("y"), constant(2)).as("instanceSetConstant") - ) + Expression.map(ImmutableMap.of("x", 1)) + .mapSet(constant("y"), constant(2)) + .as("instanceSetConstant")) .execute() .get(); @@ -1426,17 +1432,19 @@ public void testMapSet() throws Exception { assertThat((Map) data.get("multi")).containsExactly("a", 3L, "b", 2L, "c", 4L); assertThat((Map) data.get("remove")).isEmpty(); assertThat((Map) data.get("setNull")).containsExactly("a", 1L, "b", null); - + Map setDotted = (Map) data.get("setDotted"); assertThat(setDotted).containsEntry("a.b", 2L); assertThat((Map) setDotted.get("a")).containsExactly("b", 1L); assertThat((Map) data.get("setEmptyKey")).containsExactly("", "empty"); assertThat((Map) data.get("setExprVal")).containsExactly("a", 1L, "b", 3L); - assertThat((Map) data.get("setNestedMap")).isEqualTo(ImmutableMap.of("obj", ImmutableMap.of("hidden", true))); + assertThat((Map) data.get("setNestedMap")) + .isEqualTo(ImmutableMap.of("obj", ImmutableMap.of("hidden", true))); assertThat((Map) data.get("setSpecialChars")).containsExactly("~!@#$%^&*()_+", "special"); - assertThat((Map) data.get("instanceSetField")).containsExactly("foo", 1L, "instanceKey", 100L); + assertThat((Map) data.get("instanceSetField")) + .containsExactly("foo", 1L, "instanceKey", 100L); assertThat((Map) data.get("instanceSetConstant")).containsExactly("x", 1L, "y", 2L); } @@ -1455,11 +1463,11 @@ public void testMapKeys() throws Exception { Expression.mapKeys("existingField").as("existingKeys"), Expression.mapKeys(Expression.map(ImmutableMap.of("a", 1, "b", 2))).as("keys"), Expression.mapKeys(Expression.map(ImmutableMap.of())).as("empty_keys"), - Expression.mapKeys(Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_keys"), - + Expression.mapKeys( + Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))) + .as("nested_keys"), field("existingField").mapKeys().as("instanceExistingKeys"), - Expression.map(ImmutableMap.of("x", 10, "y", 20)).mapKeys().as("instanceKeys") - ) + Expression.map(ImmutableMap.of("x", 10, "y", 20)).mapKeys().as("instanceKeys")) .execute() .get(); @@ -1468,7 +1476,7 @@ public void testMapKeys() throws Exception { Map data = resultList.get(0).getData(); assertThat((List) data.get("existingKeys")).containsExactly("foo"); - assertThat((List) data.get("keys")).containsExactly("a", "b"); + assertThat((List) data.get("keys")).containsExactly("a", "b"); assertThat((List) data.get("empty_keys")).isEmpty(); assertThat((List) data.get("nested_keys")).containsExactly("a"); @@ -1491,11 +1499,11 @@ public void testMapValues() throws Exception { Expression.mapValues("existingField").as("existingValues"), Expression.mapValues(Expression.map(ImmutableMap.of("a", 1, "b", 2))).as("values"), Expression.mapValues(Expression.map(ImmutableMap.of())).as("empty_values"), - Expression.mapValues(Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_values"), - + Expression.mapValues( + Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))) + .as("nested_values"), field("existingField").mapValues().as("instanceExistingValues"), - Expression.map(ImmutableMap.of("x", 10, "y", 20)).mapValues().as("instanceValues") - ) + Expression.map(ImmutableMap.of("x", 10, "y", 20)).mapValues().as("instanceValues")) .execute() .get(); @@ -1506,7 +1514,8 @@ public void testMapValues() throws Exception { assertThat((List) data.get("existingValues")).containsExactly(1L); assertThat((List) data.get("values")).containsExactly(1L, 2L); assertThat((List) data.get("empty_values")).isEmpty(); - assertThat((List) data.get("nested_values")).containsExactly(ImmutableMap.of("nested", true)); + assertThat((List) data.get("nested_values")) + .containsExactly(ImmutableMap.of("nested", true)); assertThat((List) data.get("instanceExistingValues")).containsExactly(1L); assertThat((List) data.get("instanceValues")).containsExactly(10L, 20L); @@ -1525,13 +1534,16 @@ public void testMapEntries() throws Exception { .limit(1) .select( Expression.mapEntries("existingField").as("existingEntries"), - Expression.mapEntries(Expression.map(ImmutableMap.of("a", 1, "b", 2))).as("entries"), + Expression.mapEntries(Expression.map(ImmutableMap.of("a", 1, "b", 2))) + .as("entries"), Expression.mapEntries(Expression.map(ImmutableMap.of())).as("empty_entries"), - Expression.mapEntries(Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))).as("nested_entries"), - + Expression.mapEntries( + Expression.map(ImmutableMap.of("a", ImmutableMap.of("nested", true)))) + .as("nested_entries"), field("existingField").mapEntries().as("instanceExistingEntries"), - Expression.map(ImmutableMap.of("x", 10, "y", 20)).mapEntries().as("instanceEntries") - ) + Expression.map(ImmutableMap.of("x", 10, "y", 20)) + .mapEntries() + .as("instanceEntries")) .execute() .get(); @@ -1545,7 +1557,7 @@ public void testMapEntries() throws Exception { @SuppressWarnings("unchecked") List> entries = (List>) data.get("entries"); assertThat(entries).hasSize(2); - + // Map entry order is not guaranteed, so we check containment instead of strict ordering assertThat(entries).contains(ImmutableMap.of("k", "a", "v", 1L)); assertThat(entries).contains(ImmutableMap.of("k", "b", "v", 2L)); @@ -1558,11 +1570,13 @@ public void testMapEntries() throws Exception { .containsExactly(ImmutableMap.of("k", "foo", "v", 1L)); @SuppressWarnings("unchecked") - List> instanceEntries = (List>) data.get("instanceEntries"); + List> instanceEntries = + (List>) data.get("instanceEntries"); assertThat(instanceEntries).hasSize(2); assertThat(instanceEntries).contains(ImmutableMap.of("k", "x", "v", 10L)); assertThat(instanceEntries).contains(ImmutableMap.of("k", "y", "v", 20L)); } + @Test public void testDataManipulationExpressions() throws Exception { List results = @@ -2933,5 +2947,4 @@ public void disallowDuplicateAliasesAcrossStages() { }); assertThat(exception).hasMessageThat().contains("Duplicate alias or field name"); } - } From 38a1ff1dfd42f5a1cd8bf43b5461ee64669bd089 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Fri, 27 Feb 2026 10:16:34 -0500 Subject: [PATCH 4/5] pipeline snippets and docs fix --- .../pipeline/expressions/Expression.java | 4 +- .../example/firestore/PipelineSnippets.java | 67 +++++++++++++++---- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java index 8dfbc1423..24ccd8a34 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java @@ -1990,7 +1990,7 @@ public static Expression mapSet( * a key entirely, use {@code mapRemove}. * * - * @param mapField The map field to set entries in. + * @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. @@ -2051,7 +2051,7 @@ public static Expression mapSet( /** * Creates an expression that returns the keys of a map. * - * @param mapExpr The map expression to get the keys of. + * @param mapExpr The expression representing the map to get the keys of. * @return A new {@link Expression} representing the keys of the map. */ @BetaApi diff --git a/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java b/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java index 5731a964a..78f25bb64 100644 --- a/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java +++ b/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java @@ -1167,26 +1167,65 @@ void minLogicalFunction() throws ExecutionException, InterruptedException { void mapGetFunction() throws ExecutionException, InterruptedException { // [START map_get] Pipeline.Snapshot result = - firestore - .pipeline() - .collection("books") - .select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward")) - .execute() - .get(); + firestore + .pipeline() + .collection("books") + .select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward")) + .execute() + .get(); // [END map_get] System.out.println(result.getResults()); } void mapSetFunction() throws ExecutionException, InterruptedException { - // [START map_get] + // [START map_set] Pipeline.Snapshot result = - firestore - .pipeline() - .collection("books") - .select(mapSet(field("awards"), "pulitzer").as("awards")) - .execute() - .get(); - // [END map_get] + firestore + .pipeline() + .collection("books") + .select(mapSet(field("awards"), "pulitzer", true).as("awards")) + .execute() + .get(); + // [END map_set] + System.out.println(result.getResults()); + } + + void mapKeysFunction() throws ExecutionException, InterruptedException { + // [START map_keys] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(mapKeys(field("awards")).as("award_categories")) + .execute() + .get(); + // [END map_keys] + System.out.println(result.getResults()); + } + + void mapValuesFunction() throws ExecutionException, InterruptedException { + // [START map_values] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(mapValues(field("awards")).as("award_details")) + .execute() + .get(); + // [END map_values] + System.out.println(result.getResults()); + } + + void mapEntriesFunction() throws ExecutionException, InterruptedException { + // [START map_entries] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(mapEntries(field("awards")).as("awards_list")) + .execute() + .get(); + // [END map_entries] System.out.println(result.getResults()); } From f24ac1364551ba51a8430edbd651168e59d69e5f Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Fri, 27 Feb 2026 15:48:50 +0000 Subject: [PATCH 5/5] chore: generate libraries at Fri Feb 27 15:46:31 UTC 2026 --- .../example/firestore/PipelineSnippets.java | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java b/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java index 78f25bb64..b8a4375e6 100644 --- a/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java +++ b/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java @@ -1167,12 +1167,12 @@ void minLogicalFunction() throws ExecutionException, InterruptedException { void mapGetFunction() throws ExecutionException, InterruptedException { // [START map_get] Pipeline.Snapshot result = - firestore - .pipeline() - .collection("books") - .select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward")) - .execute() - .get(); + firestore + .pipeline() + .collection("books") + .select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward")) + .execute() + .get(); // [END map_get] System.out.println(result.getResults()); } @@ -1180,12 +1180,12 @@ void mapGetFunction() throws ExecutionException, InterruptedException { void mapSetFunction() throws ExecutionException, InterruptedException { // [START map_set] Pipeline.Snapshot result = - firestore - .pipeline() - .collection("books") - .select(mapSet(field("awards"), "pulitzer", true).as("awards")) - .execute() - .get(); + firestore + .pipeline() + .collection("books") + .select(mapSet(field("awards"), "pulitzer", true).as("awards")) + .execute() + .get(); // [END map_set] System.out.println(result.getResults()); } @@ -1193,12 +1193,12 @@ void mapSetFunction() throws ExecutionException, InterruptedException { void mapKeysFunction() throws ExecutionException, InterruptedException { // [START map_keys] Pipeline.Snapshot result = - firestore - .pipeline() - .collection("books") - .select(mapKeys(field("awards")).as("award_categories")) - .execute() - .get(); + firestore + .pipeline() + .collection("books") + .select(mapKeys(field("awards")).as("award_categories")) + .execute() + .get(); // [END map_keys] System.out.println(result.getResults()); } @@ -1206,12 +1206,12 @@ void mapKeysFunction() throws ExecutionException, InterruptedException { void mapValuesFunction() throws ExecutionException, InterruptedException { // [START map_values] Pipeline.Snapshot result = - firestore - .pipeline() - .collection("books") - .select(mapValues(field("awards")).as("award_details")) - .execute() - .get(); + firestore + .pipeline() + .collection("books") + .select(mapValues(field("awards")).as("award_details")) + .execute() + .get(); // [END map_values] System.out.println(result.getResults()); } @@ -1219,12 +1219,12 @@ void mapValuesFunction() throws ExecutionException, InterruptedException { void mapEntriesFunction() throws ExecutionException, InterruptedException { // [START map_entries] Pipeline.Snapshot result = - firestore - .pipeline() - .collection("books") - .select(mapEntries(field("awards")).as("awards_list")) - .execute() - .get(); + firestore + .pipeline() + .collection("books") + .select(mapEntries(field("awards")).as("awards_list")) + .execute() + .get(); // [END map_entries] System.out.println(result.getResults()); }