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

Added the queryTempDataset option for the BQ read options #1958

Merged
merged 7 commits into from
Oct 28, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@
String getQueryLocation();

void setQueryLocation(String query);

@TemplateParameter.Text(
order = 6,
optional = true,
description = "BigQuery temporary dataset reference when reading from the query.",
helpText =
"With this option, you can set an existing dataset to create the temporary table "
+ "to store the results of the query.",
example = "temp_dataset")
String getQueryTempDataset();

void setQueryTempDataset(String queryTempDataset);
}

/**
Expand Down Expand Up @@ -349,6 +361,7 @@
.fromQuery(options().getQuery())
.withTemplateCompatibility()
.withQueryLocation(options().getQueryLocation())
.withQueryTempDataset(options().getQueryTempDataset())

Check warning on line 364 in v2/common/src/main/java/com/google/cloud/teleport/v2/transforms/BigQueryConverters.java

View check run for this annotation

Codecov / codecov/patch

v2/common/src/main/java/com/google/cloud/teleport/v2/transforms/BigQueryConverters.java#L364

Added line #L364 was not covered by tests
.usingStandardSql());
} else {

Expand All @@ -358,7 +371,8 @@
readFunction()
.fromQuery(options().getQuery())
.withTemplateCompatibility()
.withQueryLocation(options().getQueryLocation()));
.withQueryLocation(options().getQueryLocation())
.withQueryTempDataset(options().getQueryTempDataset()));

Check warning on line 375 in v2/common/src/main/java/com/google/cloud/teleport/v2/transforms/BigQueryConverters.java

View check run for this annotation

Codecov / codecov/patch

v2/common/src/main/java/com/google/cloud/teleport/v2/transforms/BigQueryConverters.java#L374-L375

Added lines #L374 - L375 were not covered by tests
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,20 @@ public void testReadBigQueryInvalidInput() {
pipeline.run();
}

/** Tests {@link BigQueryConverters.BigQueryReadOptions} works with some options. */
@Test
public void testBigQueryReadOptions() {

BigQueryConverters.BigQueryReadOptions options =
PipelineOptionsFactory.create().as(BigQueryConverters.BigQueryReadOptions.class);

options.setInputTableSpec(null);
options.setQuery("select * from sampledb.sample_table");
options.setQueryTempDataset("temp_dataset");

assertThat(options.getQueryTempDataset()).isEqualTo("temp_dataset");
}

/**
* Tests that {@link BigQueryConverters.TableRowToFailsafeJsonDocument} transform returns the
* correct element.
Expand Down
Loading