28
28
import com .google .common .primitives .Ints ;
29
29
import java .io .Serializable ;
30
30
import java .util .List ;
31
+ import java .util .Map ;
31
32
import java .util .Objects ;
32
33
33
34
/**
@@ -53,6 +54,7 @@ public final class WriteChannelConfiguration implements LoadConfiguration, Seria
53
54
private final TimePartitioning timePartitioning ;
54
55
private final Clustering clustering ;
55
56
private final Boolean useAvroLogicalTypes ;
57
+ private final Map <String , String > labels ;
56
58
57
59
public static final class Builder implements LoadConfiguration .Builder {
58
60
@@ -70,6 +72,7 @@ public static final class Builder implements LoadConfiguration.Builder {
70
72
private TimePartitioning timePartitioning ;
71
73
private Clustering clustering ;
72
74
private Boolean useAvroLogicalTypes ;
75
+ private Map <String , String > labels ;
73
76
74
77
private Builder () {}
75
78
@@ -89,6 +92,7 @@ private Builder(WriteChannelConfiguration writeChannelConfiguration) {
89
92
this .timePartitioning = writeChannelConfiguration .timePartitioning ;
90
93
this .clustering = writeChannelConfiguration .clustering ;
91
94
this .useAvroLogicalTypes = writeChannelConfiguration .useAvroLogicalTypes ;
95
+ this .labels = writeChannelConfiguration .labels ;
92
96
}
93
97
94
98
private Builder (com .google .api .services .bigquery .model .JobConfiguration configurationPb ) {
@@ -162,6 +166,9 @@ private Builder(com.google.api.services.bigquery.model.JobConfiguration configur
162
166
this .clustering = Clustering .fromPb (loadConfigurationPb .getClustering ());
163
167
}
164
168
this .useAvroLogicalTypes = loadConfigurationPb .getUseAvroLogicalTypes ();
169
+ if (configurationPb .getLabels () != null ) {
170
+ this .labels = configurationPb .getLabels ();
171
+ }
165
172
}
166
173
167
174
@ Override
@@ -250,6 +257,11 @@ public Builder setUseAvroLogicalTypes(Boolean useAvroLogicalTypes) {
250
257
return this ;
251
258
}
252
259
260
+ public Builder setLabels (Map <String , String > labels ) {
261
+ this .labels = labels ;
262
+ return this ;
263
+ }
264
+
253
265
@ Override
254
266
public WriteChannelConfiguration build () {
255
267
return new WriteChannelConfiguration (this );
@@ -271,6 +283,7 @@ protected WriteChannelConfiguration(Builder builder) {
271
283
this .timePartitioning = builder .timePartitioning ;
272
284
this .clustering = builder .clustering ;
273
285
this .useAvroLogicalTypes = builder .useAvroLogicalTypes ;
286
+ this .labels = builder .labels ;
274
287
}
275
288
276
289
@ Override
@@ -355,6 +368,10 @@ public Boolean getUseAvroLogicalTypes() {
355
368
return useAvroLogicalTypes ;
356
369
}
357
370
371
+ public Map <String , String > getLabels () {
372
+ return labels ;
373
+ }
374
+
358
375
@ Override
359
376
public Builder toBuilder () {
360
377
return new Builder (this );
@@ -375,7 +392,8 @@ MoreObjects.ToStringHelper toStringHelper() {
375
392
.add ("autodetect" , autodetect )
376
393
.add ("timePartitioning" , timePartitioning )
377
394
.add ("clustering" , clustering )
378
- .add ("useAvroLogicalTypes" , useAvroLogicalTypes );
395
+ .add ("useAvroLogicalTypes" , useAvroLogicalTypes )
396
+ .add ("labels" , labels );
379
397
}
380
398
381
399
@ Override
@@ -405,7 +423,8 @@ public int hashCode() {
405
423
autodetect ,
406
424
timePartitioning ,
407
425
clustering ,
408
- useAvroLogicalTypes );
426
+ useAvroLogicalTypes ,
427
+ labels );
409
428
}
410
429
411
430
WriteChannelConfiguration setProjectId (String projectId ) {
@@ -416,6 +435,8 @@ WriteChannelConfiguration setProjectId(String projectId) {
416
435
}
417
436
418
437
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 ();
419
440
JobConfigurationLoad loadConfigurationPb = new JobConfigurationLoad ();
420
441
loadConfigurationPb .setDestinationTable (destinationTable .toPb ());
421
442
if (createDisposition != null ) {
@@ -471,8 +492,11 @@ com.google.api.services.bigquery.model.JobConfiguration toPb() {
471
492
loadConfigurationPb .setClustering (clustering .toPb ());
472
493
}
473
494
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 ;
476
500
}
477
501
478
502
static WriteChannelConfiguration fromPb (
0 commit comments