Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2814dc4

Browse files
feat: add MetadataCacheMode to ExternalTableDefinition (#3351)
* feat: add MetadataCacheMode to ExternalTableDefinition* Update comment* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md---------Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent4b9613d commit2814dc4

File tree

4 files changed

+74
-4
lines changed

4 files changed

+74
-4
lines changed

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ If you are using Maven without the BOM, add this to your dependencies:
5353
If you are using Gradle 5.x or later, add this to your dependencies:
5454

5555
```Groovy
56-
implementation platform('com.google.cloud:libraries-bom:26.40.0')
56+
implementation platform('com.google.cloud:libraries-bom:26.41.0')
5757
5858
implementation 'com.google.cloud:google-cloud-bigquery'
5959
```
6060
If you are using Gradle without BOM, add this to your dependencies:
6161

6262
```Groovy
63-
implementation 'com.google.cloud:google-cloud-bigquery:2.40.2'
63+
implementation 'com.google.cloud:google-cloud-bigquery:2.40.3'
6464
```
6565

6666
If you are using SBT, add this to your dependencies:
6767

6868
```Scala
69-
libraryDependencies+="com.google.cloud"%"google-cloud-bigquery"%"2.40.2"
69+
libraryDependencies+="com.google.cloud"%"google-cloud-bigquery"%"2.40.3"
7070
```
7171
<!-- {x-version-update-end}-->
7272

@@ -351,7 +351,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
351351
[kokoro-badge-link-5]:http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java11.html
352352
[stability-image]:https://img.shields.io/badge/stability-stable-green
353353
[maven-version-image]:https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquery.svg
354-
[maven-version-link]:https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquery/2.40.2
354+
[maven-version-link]:https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquery/2.40.3
355355
[authentication]:https://github.com/googleapis/google-cloud-java#authentication
356356
[auth-scopes]:https://developers.google.com/identity/protocols/oauth2/scopes
357357
[predefined-iam-roles]:https://cloud.google.com/iam/docs/understanding-roles#predefined_roles

‎google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ExternalTableDefinition.java‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,20 @@ public Builder setObjectMetadata(String objectMetadata) {
186186

187187
abstractBuildersetObjectMetadataInner(StringobjectMetadata);
188188

189+
/**
190+
* [Optional] Metadata Cache Mode for the table. Set this to enable caching of metadata from
191+
* external data source.
192+
*
193+
* @see <a
194+
* href="https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#metadatacachemode">
195+
* MetadataCacheMode</a>
196+
*/
197+
publicBuildersetMetadataCacheMode(StringmetadataCacheMode) {
198+
returnsetMetadataCacheModeInner(metadataCacheMode);
199+
}
200+
201+
abstractBuildersetMetadataCacheModeInner(StringmetadataCacheMode);
202+
189203
/** Creates an {@code ExternalTableDefinition} object. */
190204
@Override
191205
publicabstractExternalTableDefinitionbuild();
@@ -276,6 +290,21 @@ public String getObjectMetadata() {
276290
@Nullable
277291
abstractStringgetObjectMetadataInner();
278292

293+
/**
294+
* Returns the metadata cache mode.
295+
*
296+
* @see <a
297+
* href="https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#metadatacachemode">
298+
* MetadataCacheMode</a>
299+
*/
300+
@Nullable
301+
publicStringgetMetadataCacheMode() {
302+
returngetMetadataCacheModeInner();
303+
}
304+
305+
@Nullable
306+
abstractStringgetMetadataCacheModeInner();
307+
279308
/**
280309
* Returns the source format, and possibly some parsing options, of the external data. Supported
281310
* formats are {@code CSV} and {@code NEWLINE_DELIMITED_JSON}.
@@ -387,6 +416,10 @@ com.google.api.services.bigquery.model.ExternalDataConfiguration toExternalDataC
387416
externalConfigurationPb.setObjectMetadata(getObjectMetadata());
388417
}
389418

419+
if (getMetadataCacheMode() !=null) {
420+
externalConfigurationPb.setMetadataCacheMode(getMetadataCacheMode());
421+
}
422+
390423
returnexternalConfigurationPb;
391424
}
392425

@@ -580,6 +613,9 @@ static ExternalTableDefinition fromPb(Table tablePb) {
580613
if (externalDataConfiguration.getObjectMetadata() !=null) {
581614
builder.setObjectMetadata(externalDataConfiguration.getObjectMetadata());
582615
}
616+
if (externalDataConfiguration.getMetadataCacheMode() !=null) {
617+
builder.setMetadataCacheMode(externalDataConfiguration.getMetadataCacheMode());
618+
}
583619
}
584620
returnbuilder.build();
585621
}
@@ -647,6 +683,10 @@ static ExternalTableDefinition fromExternalDataConfiguration(
647683
builder.setObjectMetadata(externalDataConfiguration.getObjectMetadata());
648684
}
649685

686+
if (externalDataConfiguration.getMetadataCacheMode() !=null) {
687+
builder.setMetadataCacheMode(externalDataConfiguration.getMetadataCacheMode());
688+
}
689+
650690
returnbuilder.build();
651691
}
652692
}

‎google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalTableDefinitionTest.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public class ExternalTableDefinitionTest {
5959
.setSourceUriPrefix(SOURCE_URIS.get(0))
6060
.build();
6161
privatestaticfinalStringOBJECT_METADATA ="SIMPLE";
62+
63+
privatestaticfinalStringMETADATA_CACHE_MODE ="AUTOMATIC";
6264
privatestaticfinalExternalTableDefinitionEXTERNAL_TABLE_DEFINITION =
6365
ExternalTableDefinition.newBuilder(SOURCE_URIS,TABLE_SCHEMA,CSV_OPTIONS)
6466
.setFileSetSpecType("FILE_SET_SPEC_TYPE_FILE_SYSTEM_MATCH")
@@ -70,6 +72,7 @@ public class ExternalTableDefinitionTest {
7072
.setAutodetect(AUTODETECT)
7173
.setHivePartitioningOptions(HIVE_PARTITIONING_OPTIONS)
7274
.setObjectMetadata(OBJECT_METADATA)
75+
.setMetadataCacheMode(METADATA_CACHE_MODE)
7376
.build();
7477

7578
privatestaticfinalExternalTableDefinitionEXTERNAL_TABLE_DEFINITION_AVRO =
@@ -170,5 +173,6 @@ private void compareExternalTableDefinition(
170173
assertEquals(expected.getAutodetect(),value.getAutodetect());
171174
assertEquals(expected.getHivePartitioningOptions(),value.getHivePartitioningOptions());
172175
assertEquals(expected.getObjectMetadata(),value.getObjectMetadata());
176+
assertEquals(expected.getMetadataCacheMode(),value.getMetadataCacheMode());
173177
}
174178
}

‎google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6832,6 +6832,32 @@ public void testExternalTableMetadataCachingNotEnable() throws InterruptedExcept
68326832
assertTrue(remoteTable.delete());
68336833
}
68346834

6835+
@Test
6836+
publicvoidtestExternalMetadataCacheModeFailForNonBiglake() {
6837+
// Validate that MetadataCacheMode is passed to the backend.
6838+
// TODO: Enhance this test after BigLake testing infrastructure is inplace.
6839+
StringtableName ="test_metadata_cache_mode_fail_for_non_biglake";
6840+
TableIdtableId =TableId.of(DATASET,tableName);
6841+
ExternalTableDefinitionexternalTableDefinition =
6842+
ExternalTableDefinition.newBuilder(
6843+
"gs://" +BUCKET +"/" +JSON_LOAD_FILE,TABLE_SCHEMA,FormatOptions.json())
6844+
.setMetadataCacheMode("AUTOMATIC")
6845+
.build();
6846+
TableInfotableInfo =TableInfo.of(tableId,externalTableDefinition);
6847+
6848+
try {
6849+
bigquery.create(tableInfo);
6850+
fail("BigQueryException was expected");
6851+
}catch (BigQueryExceptione) {
6852+
BigQueryErrorerror =e.getError();
6853+
assertNotNull(error);
6854+
assertEquals("invalid",error.getReason());
6855+
assertThat(
6856+
e.getMessage().contains("metadataCacheMode provided for non BigLake external table"))
6857+
.isTrue();
6858+
}
6859+
}
6860+
68356861
@Test
68366862
publicvoidtestObjectTable()throwsInterruptedException {
68376863
StringtableName ="test_object_table";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp