Skip to content

fix(bigquery): route JOB_CREATION_REQUIRED through fast query path#13437

Open
jinseopkim0 wants to merge 2 commits into
mainfrom
fix/fast-query-latency
Open

fix(bigquery): route JOB_CREATION_REQUIRED through fast query path#13437
jinseopkim0 wants to merge 2 commits into
mainfrom
fix/fast-query-latency

Conversation

@jinseopkim0

@jinseopkim0 jinseopkim0 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Routes queries under JobCreationMode.JOB_CREATION_REQUIRED to the fast query path (jobs.query API / 1 RPC) to avoid the slow fallback path (jobs.insert API / 2 RPCs).

https://docs.cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query#QueryResponse says:

object (JobReference)

Reference to the Job that was created to run the query. This field will be present even if the original request timed out, in which case jobs.getQueryResults can be used to read the results once the query has completed. Since this API only returns the first page of results, subsequent pages can be fetched via the same mechanism (jobs.getQueryResults).

If jobCreationMode was set to JOB_CREATION_OPTIONAL and the query completes without creating a job, this field will be empty.

Thus, routing JOB_CREATION_REQUIRED through the fast path is preferred.

b/522363981

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request enables fast query support when the job creation mode is set to JOB_CREATION_REQUIRED in QueryRequestInfo. This allows queries with this configuration to execute via the fast query path, returning a TableResult directly (with both JobId and QueryId populated) rather than creating a separate job. Unit and integration tests have been updated to reflect and verify this behavior. I have no feedback to provide.

@jinseopkim0 jinseopkim0 requested a review from lqiu96 June 11, 2026 18:34
@jinseopkim0 jinseopkim0 marked this pull request as ready for review June 11, 2026 18:34
@jinseopkim0 jinseopkim0 requested review from a team as code owners June 11, 2026 18:34
&& config.getTimePartitioning() == null
&& config.getUserDefinedFunctions() == null
&& config.getWriteDisposition() == null
&& config.getJobCreationMode() != JobCreationMode.JOB_CREATION_REQUIRED;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

qq, wouldn't this just end up always doing a fast query (default is set to required)? IIUC, I think should be a fast query only for JobCreationMode.JOB_CREATION_OPTIONAL?

Is there any performance impact or behavioral change if default to a fast query even if a user explicitly sets job_required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants