Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: external table definition parquet format options #2535

Merged
merged 6 commits into from Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -52,20 +52,20 @@ If you are using Maven without BOM, add this to your dependencies:
If you are using Gradle 5.x or later, add this to your dependencies:

```Groovy
implementation platform('com.google.cloud:libraries-bom:26.8.0')
implementation platform('com.google.cloud:libraries-bom:26.9.0')

implementation 'com.google.cloud:google-cloud-bigquery'
```
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-bigquery:2.22.0'
implementation 'com.google.cloud:google-cloud-bigquery:2.23.0'
```

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

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.22.0"
libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.23.0"
```

## Authentication
Expand Down
Expand Up @@ -311,6 +311,9 @@ com.google.api.services.bigquery.model.ExternalDataConfiguration toExternalDataC
if (getDecimalTargetTypes() != null) {
externalConfigurationPb.setDecimalTargetTypes(getDecimalTargetTypes());
}
if (getFormatOptions() != null && FormatOptions.PARQUET.equals(getFormatOptions().getType())) {
externalConfigurationPb.setParquetOptions(((ParquetOptions) getFormatOptions()).toPb());
}
if (getFormatOptions() != null && FormatOptions.AVRO.equals(getFormatOptions().getType())) {
externalConfigurationPb.setAvroOptions(((AvroOptions) getFormatOptions()).toPb());
}
Expand Down
Expand Up @@ -52,6 +52,7 @@ public class ExternalTableDefinitionTest {
private static final Boolean AUTODETECT = true;
private static final AvroOptions AVRO_OPTIONS = AvroOptions.newBuilder().build();
private static final CsvOptions CSV_OPTIONS = CsvOptions.newBuilder().build();
private static final ParquetOptions PARQUET_OPTIONS = ParquetOptions.newBuilder().build();
private static final HivePartitioningOptions HIVE_PARTITIONING_OPTIONS =
HivePartitioningOptions.newBuilder()
.setMode("AUTO")
Expand All @@ -71,6 +72,9 @@ public class ExternalTableDefinitionTest {
private static final ExternalTableDefinition EXTERNAL_TABLE_DEFINITION_AVRO =
ExternalTableDefinition.newBuilder(SOURCE_URIS, TABLE_SCHEMA, AVRO_OPTIONS).build();

private static final ExternalTableDefinition EXTERNAL_TABLE_DEFINITION_PARQUET =
ExternalTableDefinition.newBuilder(SOURCE_URIS, TABLE_SCHEMA, PARQUET_OPTIONS).build();

@Test
public void testToBuilder() {
compareExternalTableDefinition(
Expand Down Expand Up @@ -136,6 +140,17 @@ public void testToAndFromPb() {
externalTableDefinition, ExternalTableDefinition.fromPb(externalTableDefinition.toPb()));
}

@Test
public void testToAndFromPbParquet() {
compareExternalTableDefinition(
EXTERNAL_TABLE_DEFINITION_PARQUET,
ExternalTableDefinition.fromPb(EXTERNAL_TABLE_DEFINITION_PARQUET.toPb()));
ExternalTableDefinition externalTableDefinition =
ExternalTableDefinition.newBuilder(SOURCE_URIS, TABLE_SCHEMA, PARQUET_OPTIONS).build();
compareExternalTableDefinition(
externalTableDefinition, ExternalTableDefinition.fromPb(externalTableDefinition.toPb()));
}

private void compareExternalTableDefinition(
ExternalTableDefinition expected, ExternalTableDefinition value) {
assertEquals(expected, value);
Expand Down