@@ -64,6 +64,7 @@ public TableFieldSchema apply(Field field) {
64
64
private final Long precision ;
65
65
private final String defaultValueExpression ;
66
66
private final String collation ;
67
+ private final FieldElementType rangeElementType ;
67
68
68
69
/**
69
70
* Mode for a BigQuery Table field. {@link Mode#NULLABLE} fields can be set to {@code null},
@@ -89,6 +90,7 @@ public static final class Builder {
89
90
private Long precision ;
90
91
private String defaultValueExpression ;
91
92
private String collation ;
93
+ private FieldElementType rangeElementType ;
92
94
93
95
private Builder () {}
94
96
@@ -104,6 +106,7 @@ private Builder(Field field) {
104
106
this .precision = field .precision ;
105
107
this .defaultValueExpression = field .defaultValueExpression ;
106
108
this .collation = field .collation ;
109
+ this .rangeElementType = field .rangeElementType ;
107
110
}
108
111
109
112
/**
@@ -292,6 +295,12 @@ public Builder setCollation(String collation) {
292
295
return this ;
293
296
}
294
297
298
+ /** Optional. Field range element type can be set only when the type of field is RANGE. */
299
+ public Builder setRangeElementType (FieldElementType rangeElementType ) {
300
+ this .rangeElementType = rangeElementType ;
301
+ return this ;
302
+ }
303
+
295
304
/** Creates a {@code Field} object. */
296
305
public Field build () {
297
306
return new Field (this );
@@ -310,6 +319,7 @@ private Field(Builder builder) {
310
319
this .precision = builder .precision ;
311
320
this .defaultValueExpression = builder .defaultValueExpression ;
312
321
this .collation = builder .collation ;
322
+ this .rangeElementType = builder .rangeElementType ;
313
323
}
314
324
315
325
/** Returns the field name. */
@@ -369,6 +379,11 @@ public String getCollation() {
369
379
return collation ;
370
380
}
371
381
382
+ /** Return the range element type the field. */
383
+ public FieldElementType getRangeElementType () {
384
+ return rangeElementType ;
385
+ }
386
+
372
387
/**
373
388
* Returns the list of sub-fields if {@link #getType()} is a {@link LegacySQLTypeName#RECORD}.
374
389
* Returns {@code null} otherwise.
@@ -395,12 +410,13 @@ public String toString() {
395
410
.add ("precision" , precision )
396
411
.add ("defaultValueExpression" , defaultValueExpression )
397
412
.add ("collation" , collation )
413
+ .add ("rangeElementType" , rangeElementType )
398
414
.toString ();
399
415
}
400
416
401
417
@ Override
402
418
public int hashCode () {
403
- return Objects .hash (name , type , mode , description , policyTags );
419
+ return Objects .hash (name , type , mode , description , policyTags , rangeElementType );
404
420
}
405
421
406
422
@ Override
@@ -484,6 +500,9 @@ TableFieldSchema toPb() {
484
500
if (collation != null ) {
485
501
fieldSchemaPb .setCollation (collation );
486
502
}
503
+ if (rangeElementType != null ) {
504
+ fieldSchemaPb .setRangeElementType (rangeElementType .toPb ());
505
+ }
487
506
return fieldSchemaPb ;
488
507
}
489
508
@@ -519,6 +538,10 @@ static Field fromPb(TableFieldSchema fieldSchemaPb) {
519
538
if (fieldSchemaPb .getCollation () != null ) {
520
539
fieldBuilder .setCollation (fieldSchemaPb .getCollation ());
521
540
}
541
+ if (fieldSchemaPb .getRangeElementType () != null ) {
542
+ fieldBuilder .setRangeElementType (
543
+ FieldElementType .fromPb (fieldSchemaPb .getRangeElementType ()));
544
+ }
522
545
return fieldBuilder .build ();
523
546
}
524
547
}
0 commit comments