From 5ab43a04f5b4034ca83b7a1b13b15b1c20432c70 Mon Sep 17 00:00:00 2001 From: Tanu Sharma Date: Wed, 21 May 2025 14:14:05 +0000 Subject: [PATCH 1/6] Adding project and database support in write transform for firestoreIO --- .../sdk/io/gcp/firestore/FirestoreV1.java | 117 ++++++++++++++++-- .../io/gcp/firestore/FirestoreV1WriteFn.java | 44 +++++-- ...V1FnBatchWriteWithDeadLetterQueueTest.java | 3 +- ...irestoreV1FnBatchWriteWithSummaryTest.java | 14 ++- .../io/gcp/firestore/it/BaseFirestoreIT.java | 11 +- .../io/gcp/firestore/it/FirestoreV1IT.java | 2 + 6 files changed, 169 insertions(+), 22 deletions(-) diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java index e9d0709343f5..0551922ae2ed 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java @@ -18,6 +18,7 @@ package org.apache.beam.sdk.io.gcp.firestore; import static java.util.Objects.requireNonNull; +import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument; import com.google.firestore.v1.BatchGetDocumentsRequest; import com.google.firestore.v1.BatchGetDocumentsResponse; @@ -47,6 +48,12 @@ import java.util.Optional; import java.util.function.Function; import javax.annotation.concurrent.Immutable; +import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.BatchGetDocuments; +import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.BatchWriteWithSummary; +import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.ListCollectionIds; +import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.ListDocuments; +import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.PartitionQuery; +import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.RunQuery; import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.BatchGetDocumentsFn; import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.ListCollectionIdsFn; import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.ListDocumentsFn; @@ -67,6 +74,7 @@ import org.apache.beam.sdk.values.PDone; import org.apache.beam.sdk.values.PInput; import org.apache.beam.sdk.values.POutput; +import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.annotations.VisibleForTesting; import org.checkerframework.checker.nullness.qual.Nullable; import org.joda.time.Instant; @@ -502,9 +510,17 @@ public PartitionQuery.Builder partitionQuery() { */ @Immutable public static final class Write { - private static final Write INSTANCE = new Write(); + private @Nullable String projectId; + private @Nullable String databaseId; - private Write() {} + public static final Write INSTANCE = new Write(null, null); + + public Write() {} + + public Write(@Nullable String projectId, @Nullable String databaseId) { + this.projectId = projectId; + this.databaseId = databaseId; + } /** * Factory method to create a new type safe builder for {@link com.google.firestore.v1.Write} @@ -537,8 +553,18 @@ private Write() {} * @see google.firestore.v1.BatchWriteResponse */ + public Write withProjectId(String projectId) { + checkArgument(projectId != null, "projectId can not be null"); + return new Write(projectId, this.databaseId); + } + + public Write withDatabaseId(String databaseId) { + checkArgument(databaseId != null, "databaseId can not be null"); + return new Write(this.projectId, databaseId); + } + public BatchWriteWithSummary.Builder batchWrite() { - return new BatchWriteWithSummary.Builder(); + return new BatchWriteWithSummary.Builder().setProjectId(projectId).setDatabaseId(databaseId); } } @@ -1348,11 +1374,18 @@ public static final class BatchWriteWithSummary BatchWriteWithSummary, BatchWriteWithSummary.Builder> { - private BatchWriteWithSummary( + private final @Nullable String projectId; + private final @Nullable String databaseId; + + public BatchWriteWithSummary( JodaClock clock, FirestoreStatefulComponentFactory firestoreStatefulComponentFactory, - RpcQosOptions rpcQosOptions) { + RpcQosOptions rpcQosOptions, + @Nullable String projectId, + @Nullable String databaseId) { super(clock, firestoreStatefulComponentFactory, rpcQosOptions); + this.projectId = projectId; + this.databaseId = databaseId; } @Override @@ -1365,7 +1398,9 @@ public PCollection expand( clock, firestoreStatefulComponentFactory, rpcQosOptions, - CounterFactory.DEFAULT))); + CounterFactory.DEFAULT, + projectId, + databaseId))); } @Override @@ -1403,6 +1438,9 @@ public static final class Builder BatchWriteWithSummary, BatchWriteWithSummary.Builder> { + private @Nullable String projectId; + private @Nullable String databaseId; + private Builder() { super(); } @@ -1414,9 +1452,33 @@ private Builder( super(clock, firestoreStatefulComponentFactory, rpcQosOptions); } + /** Set the GCP project ID to be used by the Firestore client. */ + public Builder setProjectId(@Nullable String projectId) { + this.projectId = projectId; + return this; + } + + /** Set the Firestore database ID (e.g., "(default)"). */ + public Builder setDatabaseId(@Nullable String databaseId) { + this.databaseId = databaseId; + return this; + } + + @VisibleForTesting + public @Nullable String getProjectId() { + return this.projectId; + } + + @VisibleForTesting + public @Nullable String getDatabaseId() { + return this.databaseId; + } + public BatchWriteWithDeadLetterQueue.Builder withDeadLetterQueue() { return new BatchWriteWithDeadLetterQueue.Builder( - clock, firestoreStatefulComponentFactory, rpcQosOptions); + clock, firestoreStatefulComponentFactory, rpcQosOptions) + .setProjectId(projectId) + .setDatabaseId(databaseId); } @Override @@ -1429,7 +1491,8 @@ BatchWriteWithSummary buildSafe( JodaClock clock, FirestoreStatefulComponentFactory firestoreStatefulComponentFactory, RpcQosOptions rpcQosOptions) { - return new BatchWriteWithSummary(clock, firestoreStatefulComponentFactory, rpcQosOptions); + return new BatchWriteWithSummary( + clock, firestoreStatefulComponentFactory, rpcQosOptions, projectId, databaseId); } } } @@ -1474,11 +1537,18 @@ public static final class BatchWriteWithDeadLetterQueue BatchWriteWithDeadLetterQueue, BatchWriteWithDeadLetterQueue.Builder> { + private final @Nullable String projectId; + private final @Nullable String databaseId; + private BatchWriteWithDeadLetterQueue( JodaClock clock, FirestoreStatefulComponentFactory firestoreStatefulComponentFactory, - RpcQosOptions rpcQosOptions) { + RpcQosOptions rpcQosOptions, + @Nullable String projectId, + @Nullable String databaseId) { super(clock, firestoreStatefulComponentFactory, rpcQosOptions); + this.projectId = projectId; + this.databaseId = databaseId; } @Override @@ -1490,7 +1560,9 @@ public PCollection expand(PCollection { + private @Nullable String projectId; + private @Nullable String databaseId; + private Builder() { super(); } + public Builder setProjectId(@Nullable String projectId) { + this.projectId = projectId; + return this; + } + + public Builder setDatabaseId(@Nullable String databaseId) { + this.databaseId = databaseId; + return this; + } + + @VisibleForTesting + public @Nullable String getProjectId() { + return this.projectId; + } + + @VisibleForTesting + public @Nullable String getDatabaseId() { + return this.databaseId; + } + private Builder( JodaClock clock, FirestoreStatefulComponentFactory firestoreStatefulComponentFactory, @@ -1550,7 +1645,7 @@ BatchWriteWithDeadLetterQueue buildSafe( FirestoreStatefulComponentFactory firestoreStatefulComponentFactory, RpcQosOptions rpcQosOptions) { return new BatchWriteWithDeadLetterQueue( - clock, firestoreStatefulComponentFactory, rpcQosOptions); + clock, firestoreStatefulComponentFactory, rpcQosOptions, projectId, databaseId); } } } diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1WriteFn.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1WriteFn.java index 09378d4f80c5..70c2b91ffbfd 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1WriteFn.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1WriteFn.java @@ -72,8 +72,16 @@ static final class BatchWriteFnWithSummary extends BaseBatchWriteFn extends ExplicitlyWindowedFirestore // bundle scoped state private transient FirestoreStub firestoreStub; private transient DatabaseRootName databaseRootName; + private final @Nullable String configuredProjectId; + private final @Nullable String configuredDatabaseId; @VisibleForTesting transient Queue<@NonNull WriteElement> writes = new PriorityQueue<>(WriteElement.COMPARATOR); @@ -171,12 +189,16 @@ abstract static class BaseBatchWriteFn extends ExplicitlyWindowedFirestore JodaClock clock, FirestoreStatefulComponentFactory firestoreStatefulComponentFactory, RpcQosOptions rpcQosOptions, - CounterFactory counterFactory) { + CounterFactory counterFactory, + @Nullable String configuredProjectId, + @Nullable String configuredDatabaseId) { this.clock = clock; this.firestoreStatefulComponentFactory = firestoreStatefulComponentFactory; this.rpcQosOptions = rpcQosOptions; this.counterFactory = counterFactory; this.rpcAttemptContext = V1FnRpcAttemptContext.BatchWrite; + this.configuredProjectId = configuredProjectId; + this.configuredDatabaseId = configuredDatabaseId; } @Override @@ -202,11 +224,19 @@ public void setup() { @Override public final void startBundle(StartBundleContext c) { - String project = c.getPipelineOptions().as(FirestoreOptions.class).getFirestoreProject(); + String project = + configuredProjectId != null + ? configuredProjectId + : c.getPipelineOptions().as(FirestoreOptions.class).getFirestoreProject(); + if (project == null) { project = c.getPipelineOptions().as(GcpOptions.class).getProject(); } - String databaseId = c.getPipelineOptions().as(FirestoreOptions.class).getFirestoreDb(); + + String databaseId = + configuredDatabaseId != null + ? configuredDatabaseId + : c.getPipelineOptions().as(FirestoreOptions.class).getFirestoreDb(); databaseRootName = DatabaseRootName.of( requireNonNull( diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithDeadLetterQueueTest.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithDeadLetterQueueTest.java index 2948be7658a9..35d0ea9482d3 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithDeadLetterQueueTest.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithDeadLetterQueueTest.java @@ -223,6 +223,7 @@ protected BatchWriteFnWithDeadLetterQueue getFn( RpcQosOptions rpcQosOptions, CounterFactory counterFactory, DistributionFactory distributionFactory) { - return new BatchWriteFnWithDeadLetterQueue(clock, ff, rpcQosOptions, counterFactory); + return new BatchWriteFnWithDeadLetterQueue( + clock, ff, rpcQosOptions, counterFactory, null, null); } } diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java index 70c4ce5046a5..3d188266559c 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java @@ -201,7 +201,8 @@ public void nonRetryableWriteResultStopsAttempts() throws Exception { when(callable.call(requestCaptor1.capture())).thenReturn(response1); BaseBatchWriteFn fn = - new BatchWriteFnWithSummary(clock, ff, options, CounterFactory.DEFAULT); + new BatchWriteFnWithSummary( + clock, ff, options, CounterFactory.DEFAULT, "testing-project", "(default)"); fn.setup(); fn.startBundle(startBundleContext); fn.processElement(processContext, window); // write0 @@ -238,6 +239,15 @@ public void nonRetryableWriteResultStopsAttempts() throws Exception { verifyNoMoreInteractions(callable); } + @Test + public final void testWithProjectId_thenWithDatabaseId() { + FirestoreV1.Write beamWrite = + new FirestoreV1.Write().withProjectId("my-project").withDatabaseId("(default)"); + + assertEquals("my-project", beamWrite.batchWrite().getProjectId()); + assertEquals("(default)", beamWrite.batchWrite().getDatabaseId()); + } + @Override protected BatchWriteFnWithSummary getFn( JodaClock clock, @@ -245,6 +255,6 @@ protected BatchWriteFnWithSummary getFn( RpcQosOptions rpcQosOptions, CounterFactory counterFactory, DistributionFactory distributionFactory) { - return new BatchWriteFnWithSummary(clock, ff, rpcQosOptions, counterFactory); + return new BatchWriteFnWithSummary(clock, ff, rpcQosOptions, counterFactory, null, null); } } diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/it/BaseFirestoreIT.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/it/BaseFirestoreIT.java index 509797892e04..8695080cb885 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/it/BaseFirestoreIT.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/it/BaseFirestoreIT.java @@ -92,10 +92,12 @@ abstract class BaseFirestoreIT { .build(); protected static String project; + protected static String databaseId; @Before public void setup() { project = TestPipeline.testingPipelineOptions().as(GcpOptions.class).getProject(); + databaseId = "firestoredb"; } private static Instant toWriteTime(WriteResult result) { @@ -441,7 +443,14 @@ protected final void runWriteTest( testPipeline .apply(Create.of(Collections.singletonList(documentIds))) .apply(createWrite) - .apply(FirestoreIO.v1().write().batchWrite().withRpcQosOptions(RPC_QOS_OPTIONS).build()); + .apply( + FirestoreIO.v1() + .write() + .withProjectId(project) + .withDatabaseId(databaseId) + .batchWrite() + .withRpcQosOptions(RPC_QOS_OPTIONS) + .build()); testPipeline.run(TestPipeline.testingPipelineOptions()); diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/it/FirestoreV1IT.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/it/FirestoreV1IT.java index 204aa67619bd..dce3ca4b8753 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/it/FirestoreV1IT.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/it/FirestoreV1IT.java @@ -116,6 +116,8 @@ public void batchWrite_partialFailureOutputsToDeadLetterQueue() .apply( FirestoreIO.v1() .write() + .withProjectId(project) + .withDatabaseId(databaseId) .batchWrite() .withDeadLetterQueue() .withRpcQosOptions(options) From 7fb24eab55418e6eef65b0b6f73f638048676f3c Mon Sep 17 00:00:00 2001 From: Tanu Sharma Date: Fri, 23 May 2025 08:56:57 +0000 Subject: [PATCH 2/6] Spotless Apply --- .../org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java | 6 ------ .../firestore/FirestoreV1FnBatchWriteWithSummaryTest.java | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java index 0551922ae2ed..8d42e92111d6 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java @@ -48,12 +48,6 @@ import java.util.Optional; import java.util.function.Function; import javax.annotation.concurrent.Immutable; -import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.BatchGetDocuments; -import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.BatchWriteWithSummary; -import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.ListCollectionIds; -import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.ListDocuments; -import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.PartitionQuery; -import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1.RunQuery; import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.BatchGetDocumentsFn; import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.ListCollectionIdsFn; import org.apache.beam.sdk.io.gcp.firestore.FirestoreV1ReadFn.ListDocumentsFn; diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java index 3d188266559c..7150b1c057bd 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java @@ -240,7 +240,7 @@ public void nonRetryableWriteResultStopsAttempts() throws Exception { } @Test - public final void testWithProjectId_thenWithDatabaseId() { + public void testWithProjectId_thenWithDatabaseId() { FirestoreV1.Write beamWrite = new FirestoreV1.Write().withProjectId("my-project").withDatabaseId("(default)"); From db04c36d704ea3e3d6ca236bbcf3115d16e22c0c Mon Sep 17 00:00:00 2001 From: Tanu Sharma Date: Wed, 4 Jun 2025 07:13:01 +0000 Subject: [PATCH 3/6] Resolving comments --- .../sdk/io/gcp/firestore/FirestoreV1.java | 25 +++++++++---------- ...irestoreV1FnBatchWriteWithSummaryTest.java | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java index 8d42e92111d6..a9ec69ad4d06 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java @@ -507,14 +507,9 @@ public static final class Write { private @Nullable String projectId; private @Nullable String databaseId; - public static final Write INSTANCE = new Write(null, null); + private static final Write INSTANCE = new Write(); - public Write() {} - - public Write(@Nullable String projectId, @Nullable String databaseId) { - this.projectId = projectId; - this.databaseId = databaseId; - } + private Write() {} /** * Factory method to create a new type safe builder for {@link com.google.firestore.v1.Write} @@ -549,12 +544,16 @@ public Write(@Nullable String projectId, @Nullable String databaseId) { */ public Write withProjectId(String projectId) { checkArgument(projectId != null, "projectId can not be null"); - return new Write(projectId, this.databaseId); + // return new Write(projectId, this.databaseId); + this.projectId = projectId; + return this; } public Write withDatabaseId(String databaseId) { checkArgument(databaseId != null, "databaseId can not be null"); - return new Write(this.projectId, databaseId); + // return new Write(this.projectId, databaseId); + this.databaseId = databaseId; + return this; } public BatchWriteWithSummary.Builder batchWrite() { @@ -1447,13 +1446,13 @@ private Builder( } /** Set the GCP project ID to be used by the Firestore client. */ - public Builder setProjectId(@Nullable String projectId) { + private Builder setProjectId(@Nullable String projectId) { this.projectId = projectId; return this; } /** Set the Firestore database ID (e.g., "(default)"). */ - public Builder setDatabaseId(@Nullable String databaseId) { + private Builder setDatabaseId(@Nullable String databaseId) { this.databaseId = databaseId; return this; } @@ -1601,12 +1600,12 @@ private Builder() { super(); } - public Builder setProjectId(@Nullable String projectId) { + private Builder setProjectId(@Nullable String projectId) { this.projectId = projectId; return this; } - public Builder setDatabaseId(@Nullable String databaseId) { + private Builder setDatabaseId(@Nullable String databaseId) { this.databaseId = databaseId; return this; } diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java index 7150b1c057bd..3e37e3975bf5 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1FnBatchWriteWithSummaryTest.java @@ -242,7 +242,7 @@ public void nonRetryableWriteResultStopsAttempts() throws Exception { @Test public void testWithProjectId_thenWithDatabaseId() { FirestoreV1.Write beamWrite = - new FirestoreV1.Write().withProjectId("my-project").withDatabaseId("(default)"); + FirestoreIO.v1().write().withProjectId("my-project").withDatabaseId("(default)"); assertEquals("my-project", beamWrite.batchWrite().getProjectId()); assertEquals("(default)", beamWrite.batchWrite().getDatabaseId()); From 19d4595530c2e9b1940d911287de86229b11ad16 Mon Sep 17 00:00:00 2001 From: Tanu Sharma Date: Wed, 4 Jun 2025 07:16:43 +0000 Subject: [PATCH 4/6] Removing useless comments --- .../java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java index a9ec69ad4d06..a249ebaeadd7 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java @@ -544,14 +544,12 @@ private Write() {} */ public Write withProjectId(String projectId) { checkArgument(projectId != null, "projectId can not be null"); - // return new Write(projectId, this.databaseId); this.projectId = projectId; return this; } public Write withDatabaseId(String databaseId) { checkArgument(databaseId != null, "databaseId can not be null"); - // return new Write(this.projectId, databaseId); this.databaseId = databaseId; return this; } From 4efd6ba70631c73169263a81ff1688994f254b6e Mon Sep 17 00:00:00 2001 From: Tanu Sharma Date: Thu, 5 Jun 2025 16:46:22 +0000 Subject: [PATCH 5/6] public to private --- .../org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java index a249ebaeadd7..24b81f9b7b79 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java @@ -1456,12 +1456,12 @@ private Builder setDatabaseId(@Nullable String databaseId) { } @VisibleForTesting - public @Nullable String getProjectId() { + @Nullable String getProjectId() { return this.projectId; } @VisibleForTesting - public @Nullable String getDatabaseId() { + @Nullable String getDatabaseId() { return this.databaseId; } @@ -1609,12 +1609,12 @@ private Builder setDatabaseId(@Nullable String databaseId) { } @VisibleForTesting - public @Nullable String getProjectId() { + @Nullable String getProjectId() { return this.projectId; } @VisibleForTesting - public @Nullable String getDatabaseId() { + @Nullable String getDatabaseId() { return this.databaseId; } From 829da7aaf1fe702c66b05c53a64e365139a9fd9e Mon Sep 17 00:00:00 2001 From: Tanu Sharma Date: Wed, 11 Jun 2025 15:37:56 +0000 Subject: [PATCH 6/6] Spotless apply --- .../beam/sdk/io/gcp/firestore/FirestoreV1.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java index 24b81f9b7b79..446d097a8ed8 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1.java @@ -1456,12 +1456,14 @@ private Builder setDatabaseId(@Nullable String databaseId) { } @VisibleForTesting - @Nullable String getProjectId() { + @Nullable + String getProjectId() { return this.projectId; } @VisibleForTesting - @Nullable String getDatabaseId() { + @Nullable + String getDatabaseId() { return this.databaseId; } @@ -1609,12 +1611,14 @@ private Builder setDatabaseId(@Nullable String databaseId) { } @VisibleForTesting - @Nullable String getProjectId() { + @Nullable + String getProjectId() { return this.projectId; } @VisibleForTesting - @Nullable String getDatabaseId() { + @Nullable + String getDatabaseId() { return this.databaseId; }