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: make sure to fall back to old query path when query job is incomplete #941

Merged
merged 5 commits into from Nov 13, 2020
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
Expand Up @@ -1268,7 +1268,7 @@ public com.google.api.services.bigquery.model.QueryResponse call() {

long numRows;
Schema schema;
if (results.getSchema() == null && results.getJobComplete()) {
if ((results.getSchema() == null && results.getJobComplete()) || !results.getJobComplete()) {
stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
JobId jobId = JobId.fromPb(results.getJobReference());
Job job = getJob(jobId, options);
TableResult tableResult = job.getQueryResults();
Expand Down
Expand Up @@ -1813,6 +1813,36 @@ public void testFastDDLQuery() throws InterruptedException {
}
}

@Test
public void testFastQuerySlowDDL() throws InterruptedException {
String tableName =
stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
"test_table_fast_query_ddl_slow_" + UUID.randomUUID().toString().substring(0, 8);
// This query take more than 10s to run and should fall back on the old query path
String slowDdlQuery =
String.format(
"CREATE OR REPLACE TABLE %s AS SELECT unique_key, agency, complaint_type, descriptor, street_name, city, landmark FROM `bigquery-public-data.new_york.311_service_requests`",
tableName);
QueryJobConfiguration ddlConfig =
QueryJobConfiguration.newBuilder(slowDdlQuery)
.setDefaultDataset(DatasetId.of(DATASET))
.build();
TableResult result = bigquery.query(ddlConfig);
assertEquals(0, result.getTotalRows());
assertNotNull(result.getSchema());
// Verify correctness of table content
String sqlQuery = String.format("SELECT * FROM %s.%s", DATASET, tableName);
QueryJobConfiguration sqlConfig = QueryJobConfiguration.newBuilder(sqlQuery).build();
TableResult resultAfterDDL = bigquery.query(sqlConfig);
for (FieldValueList row : resultAfterDDL.getValues()) {
FieldValue unique_key = row.get(0);
assertEquals(unique_key, row.get("unique_key"));
FieldValue agency = row.get(1);
assertEquals(agency, row.get("agency"));
FieldValue complaint_type = row.get(2);
assertEquals(complaint_type, row.get("complaint_type"));
}
}

@Test
public void testFastQueryHTTPException() throws InterruptedException {
String queryInvalid =
Expand Down