@@ -200,6 +200,20 @@ public Builder setMetadataCacheMode(String metadataCacheMode) {
200
200
201
201
abstract Builder setMetadataCacheModeInner (String metadataCacheMode );
202
202
203
+ /**
204
+ * [Optional] Metadata Cache Mode for the table. Set this to enable caching of metadata from
205
+ * external data source.
206
+ *
207
+ * @see <a
208
+ * href="https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#resource:-table">
209
+ * MaxStaleness</a>
210
+ */
211
+ public Builder setMaxStaleness (String maxStaleness ) {
212
+ return setMaxStalenessInner (maxStaleness );
213
+ }
214
+
215
+ abstract Builder setMaxStalenessInner (String maxStaleness );
216
+
203
217
/** Creates an {@code ExternalTableDefinition} object. */
204
218
@ Override
205
219
public abstract ExternalTableDefinition build ();
@@ -305,6 +319,22 @@ public String getMetadataCacheMode() {
305
319
@ Nullable
306
320
abstract String getMetadataCacheModeInner ();
307
321
322
+ /**
323
+ * Returns the maximum staleness of data that could be returned when the table is queried.
324
+ * Staleness encoded as a string encoding of sql IntervalValue type.
325
+ *
326
+ * @see <a
327
+ * href="hhttps://cloud.google.com/bigquery/docs/reference/rest/v2/tables#resource:-table">
328
+ * MaxStaleness</a>
329
+ */
330
+ @ Nullable
331
+ public String getMaxStaleness () {
332
+ return getMaxStalenessInner ();
333
+ }
334
+
335
+ @ Nullable
336
+ abstract String getMaxStalenessInner ();
337
+
308
338
/**
309
339
* Returns the source format, and possibly some parsing options, of the external data. Supported
310
340
* formats are {@code CSV} and {@code NEWLINE_DELIMITED_JSON}.
@@ -351,6 +381,9 @@ public HivePartitioningOptions getHivePartitioningOptions() {
351
381
com .google .api .services .bigquery .model .Table toPb () {
352
382
Table tablePb = super .toPb ();
353
383
tablePb .setExternalDataConfiguration (toExternalDataConfigurationPb ());
384
+ if (getMaxStaleness () != null ) {
385
+ tablePb .setMaxStaleness (getMaxStaleness ());
386
+ }
354
387
return tablePb ;
355
388
}
356
389
@@ -616,6 +649,9 @@ static ExternalTableDefinition fromPb(Table tablePb) {
616
649
if (externalDataConfiguration .getMetadataCacheMode () != null ) {
617
650
builder .setMetadataCacheMode (externalDataConfiguration .getMetadataCacheMode ());
618
651
}
652
+ if (tablePb .getMaxStaleness () != null ) {
653
+ builder .setMaxStaleness (tablePb .getMaxStaleness ());
654
+ }
619
655
}
620
656
return builder .build ();
621
657
}
0 commit comments