@@ -131,6 +131,9 @@ private Object writeReplace() {
131
131
case DATE :
132
132
builder .set (fieldName ).to ((Date ) value );
133
133
break ;
134
+ case INTERVAL :
135
+ builder .set (fieldName ).to ((Interval ) value );
136
+ break ;
134
137
case ARRAY :
135
138
final Type elementType = fieldType .getArrayElementType ();
136
139
switch (elementType .getCode ()) {
@@ -184,6 +187,9 @@ private Object writeReplace() {
184
187
case DATE :
185
188
builder .set (fieldName ).toDateArray ((Iterable <Date >) value );
186
189
break ;
190
+ case INTERVAL :
191
+ builder .set (fieldName ).toIntervalArray ((Iterable <Interval >) value );
192
+ break ;
187
193
case STRUCT :
188
194
builder .set (fieldName ).toStructArray (elementType , (Iterable <Struct >) value );
189
195
break ;
@@ -298,6 +304,9 @@ private static Object decodeValue(Type fieldType, com.google.protobuf.Value prot
298
304
case DATE :
299
305
checkType (fieldType , proto , KindCase .STRING_VALUE );
300
306
return Date .parseDate (proto .getStringValue ());
307
+ case INTERVAL :
308
+ checkType (fieldType , proto , KindCase .STRING_VALUE );
309
+ return Interval .parseFromString (proto .getStringValue ());
301
310
case ARRAY :
302
311
checkType (fieldType , proto , KindCase .LIST_VALUE );
303
312
ListValue listValue = proto .getListValue ();
@@ -347,6 +356,7 @@ static Object decodeArrayValue(Type elementType, ListValue listValue) {
347
356
case BYTES :
348
357
case TIMESTAMP :
349
358
case DATE :
359
+ case INTERVAL :
350
360
case STRUCT :
351
361
case PROTO :
352
362
return Lists .transform (listValue .getValuesList (), input -> decodeValue (elementType , input ));
@@ -503,6 +513,12 @@ protected Date getDateInternal(int columnIndex) {
503
513
return (Date ) rowData .get (columnIndex );
504
514
}
505
515
516
+ @ Override
517
+ protected Interval getIntervalInternal (int columnIndex ) {
518
+ ensureDecoded (columnIndex );
519
+ return (Interval ) rowData .get (columnIndex );
520
+ }
521
+
506
522
private boolean isUnrecognizedType (int columnIndex ) {
507
523
return type .getStructFields ().get (columnIndex ).getType ().getCode () == Code .UNRECOGNIZED ;
508
524
}
@@ -624,6 +640,8 @@ protected Value getValueInternal(int columnIndex) {
624
640
return Value .timestamp (isNull ? null : getTimestampInternal (columnIndex ));
625
641
case DATE :
626
642
return Value .date (isNull ? null : getDateInternal (columnIndex ));
643
+ case INTERVAL :
644
+ return Value .interval (isNull ? null : getIntervalInternal (columnIndex ));
627
645
case STRUCT :
628
646
return Value .struct (isNull ? null : getStructInternal (columnIndex ));
629
647
case UNRECOGNIZED :
@@ -664,6 +682,8 @@ protected Value getValueInternal(int columnIndex) {
664
682
return Value .timestampArray (isNull ? null : getTimestampListInternal (columnIndex ));
665
683
case DATE :
666
684
return Value .dateArray (isNull ? null : getDateListInternal (columnIndex ));
685
+ case INTERVAL :
686
+ return Value .intervalArray (isNull ? null : getIntervalListInternal (columnIndex ));
667
687
case STRUCT :
668
688
return Value .structArray (
669
689
elementType , isNull ? null : getStructListInternal (columnIndex ));
@@ -847,6 +867,13 @@ protected List<Date> getDateListInternal(int columnIndex) {
847
867
return Collections .unmodifiableList ((List <Date >) rowData .get (columnIndex ));
848
868
}
849
869
870
+ @ Override
871
+ @ SuppressWarnings ("unchecked" ) // We know ARRAY<Interval> produces a List<Interval>.
872
+ protected List <Interval > getIntervalListInternal (int columnIndex ) {
873
+ ensureDecoded (columnIndex );
874
+ return Collections .unmodifiableList ((List <Interval >) rowData .get (columnIndex ));
875
+ }
876
+
850
877
@ Override
851
878
@ SuppressWarnings ("unchecked" ) // We know ARRAY<STRUCT<...>> produces a List<STRUCT>.
852
879
protected List <Struct > getStructListInternal (int columnIndex ) {
0 commit comments