2828import com .google .common .primitives .Ints ;
2929import java .io .Serializable ;
3030import java .util .List ;
31+ import java .util .Map ;
3132import java .util .Objects ;
3233
3334/**
@@ -53,6 +54,7 @@ public final class WriteChannelConfiguration implements LoadConfiguration, Seria
5354 private final TimePartitioning timePartitioning ;
5455 private final Clustering clustering ;
5556 private final Boolean useAvroLogicalTypes ;
57+ private final Map <String , String > labels ;
5658
5759 public static final class Builder implements LoadConfiguration .Builder {
5860
@@ -70,6 +72,7 @@ public static final class Builder implements LoadConfiguration.Builder {
7072 private TimePartitioning timePartitioning ;
7173 private Clustering clustering ;
7274 private Boolean useAvroLogicalTypes ;
75+ private Map <String , String > labels ;
7376
7477 private Builder () {}
7578
@@ -89,6 +92,7 @@ private Builder(WriteChannelConfiguration writeChannelConfiguration) {
8992 this .timePartitioning = writeChannelConfiguration .timePartitioning ;
9093 this .clustering = writeChannelConfiguration .clustering ;
9194 this .useAvroLogicalTypes = writeChannelConfiguration .useAvroLogicalTypes ;
95+ this .labels = writeChannelConfiguration .labels ;
9296 }
9397
9498 private Builder (com .google .api .services .bigquery .model .JobConfiguration configurationPb ) {
@@ -162,6 +166,9 @@ private Builder(com.google.api.services.bigquery.model.JobConfiguration configur
162166 this .clustering = Clustering .fromPb (loadConfigurationPb .getClustering ());
163167 }
164168 this .useAvroLogicalTypes = loadConfigurationPb .getUseAvroLogicalTypes ();
169+ if (configurationPb .getLabels () != null ) {
170+ this .labels = configurationPb .getLabels ();
171+ }
165172 }
166173
167174 @ Override
@@ -250,6 +257,11 @@ public Builder setUseAvroLogicalTypes(Boolean useAvroLogicalTypes) {
250257 return this ;
251258 }
252259
260+ public Builder setLabels (Map <String , String > labels ) {
261+ this .labels = labels ;
262+ return this ;
263+ }
264+
253265 @ Override
254266 public WriteChannelConfiguration build () {
255267 return new WriteChannelConfiguration (this );
@@ -271,6 +283,7 @@ protected WriteChannelConfiguration(Builder builder) {
271283 this .timePartitioning = builder .timePartitioning ;
272284 this .clustering = builder .clustering ;
273285 this .useAvroLogicalTypes = builder .useAvroLogicalTypes ;
286+ this .labels = builder .labels ;
274287 }
275288
276289 @ Override
@@ -355,6 +368,10 @@ public Boolean getUseAvroLogicalTypes() {
355368 return useAvroLogicalTypes ;
356369 }
357370
371+ public Map <String , String > getLabels () {
372+ return labels ;
373+ }
374+
358375 @ Override
359376 public Builder toBuilder () {
360377 return new Builder (this );
@@ -375,7 +392,8 @@ MoreObjects.ToStringHelper toStringHelper() {
375392 .add ("autodetect" , autodetect )
376393 .add ("timePartitioning" , timePartitioning )
377394 .add ("clustering" , clustering )
378- .add ("useAvroLogicalTypes" , useAvroLogicalTypes );
395+ .add ("useAvroLogicalTypes" , useAvroLogicalTypes )
396+ .add ("labels" , labels );
379397 }
380398
381399 @ Override
@@ -405,7 +423,8 @@ public int hashCode() {
405423 autodetect ,
406424 timePartitioning ,
407425 clustering ,
408- useAvroLogicalTypes );
426+ useAvroLogicalTypes ,
427+ labels );
409428 }
410429
411430 WriteChannelConfiguration setProjectId (String projectId ) {
@@ -416,6 +435,8 @@ WriteChannelConfiguration setProjectId(String projectId) {
416435 }
417436
418437 com .google .api .services .bigquery .model .JobConfiguration toPb () {
438+ com .google .api .services .bigquery .model .JobConfiguration jobConfiguration =
439+ new com .google .api .services .bigquery .model .JobConfiguration ();
419440 JobConfigurationLoad loadConfigurationPb = new JobConfigurationLoad ();
420441 loadConfigurationPb .setDestinationTable (destinationTable .toPb ());
421442 if (createDisposition != null ) {
@@ -471,8 +492,11 @@ com.google.api.services.bigquery.model.JobConfiguration toPb() {
471492 loadConfigurationPb .setClustering (clustering .toPb ());
472493 }
473494 loadConfigurationPb .setUseAvroLogicalTypes (useAvroLogicalTypes );
474- return new com .google .api .services .bigquery .model .JobConfiguration ()
475- .setLoad (loadConfigurationPb );
495+ if (labels != null ) {
496+ jobConfiguration .setLabels (labels );
497+ }
498+ jobConfiguration .setLoad (loadConfigurationPb );
499+ return jobConfiguration ;
476500 }
477501
478502 static WriteChannelConfiguration fromPb (
0 commit comments