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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ 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.23.0'
implementation 'com.google.cloud:google-cloud-bigquery:2.23.1'
```

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

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

## Authentication
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static FormatOptions googleSheets() {

/** Default options for PARQUET format. */
public static FormatOptions parquet() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the return type as is.
Changing it will break existing customers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

should i handle squashing commits myself or is it done at merge time?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jbeluch. The commits should be updated now.

return new FormatOptions(PARQUET);
return ParquetOptions.newBuilder().build();
}

/** Default options for the ORC format. */
Expand Down
Original file line number Diff line number Diff line change
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