@@ -135,6 +135,14 @@ public Builder setFormatOptions(FormatOptions formatOptions) {
135
135
/** Sets the table schema. */
136
136
public abstract Builder setSchema (Schema schema );
137
137
138
+ /** Sets the table Hive partitioning options. */
139
+ public Builder setHivePartitioningOptions (HivePartitioningOptions hivePartitioningOptions ) {
140
+ return setHivePartitioningOptionsInner (hivePartitioningOptions );
141
+ };
142
+
143
+ abstract Builder setHivePartitioningOptionsInner (
144
+ HivePartitioningOptions hivePartitioningOptions );
145
+
138
146
/** Creates an {@code ExternalTableDefinition} object. */
139
147
@ Override
140
148
public abstract ExternalTableDefinition build ();
@@ -212,6 +220,19 @@ public <F extends FormatOptions> F getFormatOptions() {
212
220
@ Nullable
213
221
public abstract Boolean getAutodetect ();
214
222
223
+ /**
224
+ * [Experimental] Returns the HivePartitioningOptions when the data layout follows Hive
225
+ * partitioning convention
226
+ */
227
+ @ SuppressWarnings ("unchecked" )
228
+ @ Nullable
229
+ public HivePartitioningOptions getHivePartitioningOptions () {
230
+ return getHivePartitioningOptionsInner ();
231
+ }
232
+
233
+ @ Nullable
234
+ abstract HivePartitioningOptions getHivePartitioningOptionsInner ();
235
+
215
236
/** Returns a builder for the {@code ExternalTableDefinition} object. */
216
237
public abstract Builder toBuilder ();
217
238
@@ -257,6 +278,9 @@ com.google.api.services.bigquery.model.ExternalDataConfiguration toExternalDataC
257
278
if (getAutodetect () != null ) {
258
279
externalConfigurationPb .setAutodetect (getAutodetect ());
259
280
}
281
+ if (getHivePartitioningOptions () != null ) {
282
+ externalConfigurationPb .setHivePartitioningOptions (getHivePartitioningOptions ().toPb ());
283
+ }
260
284
return externalConfigurationPb ;
261
285
}
262
286
@@ -405,6 +429,10 @@ static ExternalTableDefinition fromPb(Table tablePb) {
405
429
}
406
430
builder .setMaxBadRecords (externalDataConfiguration .getMaxBadRecords ());
407
431
builder .setAutodetect (externalDataConfiguration .getAutodetect ());
432
+ if (externalDataConfiguration .getHivePartitioningOptions () != null ) {
433
+ builder .setHivePartitioningOptions (
434
+ HivePartitioningOptions .fromPb (externalDataConfiguration .getHivePartitioningOptions ()));
435
+ }
408
436
}
409
437
return builder .build ();
410
438
}
@@ -444,6 +472,10 @@ static ExternalTableDefinition fromExternalDataConfiguration(
444
472
if (externalDataConfiguration .getAutodetect () != null ) {
445
473
builder .setAutodetect (externalDataConfiguration .getAutodetect ());
446
474
}
475
+ if (externalDataConfiguration .getHivePartitioningOptions () != null ) {
476
+ builder .setHivePartitioningOptions (
477
+ HivePartitioningOptions .fromPb (externalDataConfiguration .getHivePartitioningOptions ()));
478
+ }
447
479
return builder .build ();
448
480
}
449
481
}
0 commit comments