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

feat: add fast query path support when empty jobId object is passed #2349

Merged
merged 17 commits into from
Nov 11, 2022
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.
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 @@ -1294,7 +1294,7 @@ public TableResult query(QueryJobConfiguration configuration, JobOption... optio
// If all parameters passed in configuration are supported by the query() method on the backend,
// put on fast path
QueryRequestInfo requestInfo = new QueryRequestInfo(configuration);
if (requestInfo.isFastQuerySupported()) {
if (requestInfo.isFastQuerySupported(null)) {
String projectId = getOptions().getProjectId();
QueryRequest content = requestInfo.toPb();
return queryRpc(projectId, content, options);
Expand Down Expand Up @@ -1379,6 +1379,14 @@ public com.google.api.services.bigquery.model.QueryResponse call() {
public TableResult query(QueryJobConfiguration configuration, JobId jobId, JobOption... options)
throws InterruptedException, JobException {
Job.checkNotDryRun(configuration, "query");
// If all parameters passed in configuration are supported by the query() method on the backend,
// put on fast path
QueryRequestInfo requestInfo = new QueryRequestInfo(configuration);
if (requestInfo.isFastQuerySupported(jobId)) {
Neenu1995 marked this conversation as resolved.
Show resolved Hide resolved
String projectId = getOptions().getProjectId();
Neenu1995 marked this conversation as resolved.
Show resolved Hide resolved
QueryRequest content = requestInfo.toPb();
return queryRpc(projectId, content, options);
}
return create(JobInfo.of(jobId, configuration), options).getQueryResults();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final class QueryRequestInfo {
this.useQueryCache = config.useQueryCache();
}

boolean isFastQuerySupported() {
boolean isFastQuerySupported(JobId jobId) {
return config.getClustering() == null
&& config.getCreateDisposition() == null
&& config.getDestinationEncryptionConfiguration() == null
Expand All @@ -70,7 +70,9 @@ boolean isFastQuerySupported() {
&& config.getTableDefinitions() == null
&& config.getTimePartitioning() == null
&& config.getUserDefinedFunctions() == null
&& config.getWriteDisposition() == null;
&& config.getWriteDisposition() == null
&& jobId.getJob() == null
Neenu1995 marked this conversation as resolved.
Show resolved Hide resolved
&& jobId.getLocation() != null;
}

QueryRequest toPb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ public class QueryRequestInfoTest {

@Test
public void testIsFastQuerySupported() {
assertEquals(false, REQUEST_INFO.isFastQuerySupported());
assertEquals(true, REQUEST_INFO_SUPPORTED.isFastQuerySupported());
JobId jobIdSupported = JobId.newBuilder().setLocation("US").build();
JobId jobIdNotSupported = JobId.newBuilder().setJob("random-job-id").build();
assertEquals(false, REQUEST_INFO.isFastQuerySupported(jobIdSupported));
assertEquals(true, REQUEST_INFO_SUPPORTED.isFastQuerySupported(jobIdSupported));
assertEquals(false, REQUEST_INFO.isFastQuerySupported(jobIdNotSupported));
assertEquals(false, REQUEST_INFO_SUPPORTED.isFastQuerySupported(jobIdNotSupported));
}

@Test
Expand Down