Skip to content

Commit c7f2cab

Browse files
authored
[CherryPick][#23062] Fix Java Examples_Flink in 2.42.0 release. (#23605)
1 parent 926fb53 commit c7f2cab

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BatchLoads.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ class BatchLoads<DestinationT, ElementT>
146146
private final Coder<ElementT> elementCoder;
147147
private final RowWriterFactory<ElementT, DestinationT> rowWriterFactory;
148148
private final @Nullable String kmsKey;
149-
private final boolean clusteringEnabled;
150149
private final String tempDataset;
150+
private Coder<TableDestination> tableDestinationCoder;
151151

152152
// The maximum number of times to retry failed load or copy jobs.
153153
private int maxRetryJobs = DEFAULT_MAX_RETRY_JOBS;
@@ -186,9 +186,10 @@ class BatchLoads<DestinationT, ElementT>
186186
this.elementCoder = elementCoder;
187187
this.kmsKey = kmsKey;
188188
this.rowWriterFactory = rowWriterFactory;
189-
this.clusteringEnabled = clusteringEnabled;
190189
schemaUpdateOptions = Collections.emptySet();
191190
this.tempDataset = tempDataset;
191+
this.tableDestinationCoder =
192+
clusteringEnabled ? TableDestinationCoderV3.of() : TableDestinationCoderV2.of();
192193
}
193194

194195
void setSchemaUpdateOptions(Set<SchemaUpdateOption> schemaUpdateOptions) {
@@ -493,7 +494,8 @@ public WriteResult expandUntriggered(PCollection<KV<DestinationT, ElementT>> inp
493494
maxRetryJobs,
494495
kmsKey,
495496
loadJobProjectId))
496-
.withSideInputs(copyJobIdPrefixView));
497+
.withSideInputs(copyJobIdPrefixView))
498+
.setCoder(tableDestinationCoder);
497499

498500
PCollectionList<TableDestination> allSuccessfulWrites =
499501
PCollectionList.of(successfulSinglePartitionWrites).and(successfulMultiPartitionWrites);
@@ -755,9 +757,6 @@ PCollection<TableDestination> writeSinglePartition(
755757
List<PCollectionView<?>> sideInputs = Lists.newArrayList(loadJobIdPrefixView);
756758
sideInputs.addAll(dynamicDestinations.getSideInputs());
757759

758-
Coder<TableDestination> tableDestinationCoder =
759-
clusteringEnabled ? TableDestinationCoderV3.of() : TableDestinationCoderV2.of();
760-
761760
Coder<KV<ShardedKey<DestinationT>, WritePartition.Result>> partitionsCoder =
762761
KvCoder.of(
763762
ShardedKeyCoder.of(NullableCoder.of(destinationCoder)),

0 commit comments

Comments
 (0)