-
Notifications
You must be signed in to change notification settings - Fork 33
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
Support stateless queries. #184
Conversation
From https://cloud.google.com/java/docs/reference/google-cloud-bigquery/2.34.1/com.google.cloud.bigquery.BigQuery > Stateless queries: query execution without corresponding job metadata Stateless queries are currently in preview. This PR introduces support for stateless queries via a new JDBC query parameter. Set `jobcreationmode` to a string that matches one of the standard `JobCreationMode` enum values: - `JOB_CREATION_MODE_UNSPECIFIED`: Unspecified JobCreationMode, defaults to `JOB_CREATION_REQUIRED`. - `JOB_CREATION_REQUIRED`: Default. Job creation is always required. - `JOB_CREATION_OPTIONAL`: Job creation is optional. Returning immediate results is prioritized. BigQuery will automatically determine if a Job needs to be created. The conditions under which BigQuery can decide to not create a Job are subject to change. If Job creation is required, JOB_CREATION_REQUIRED mode should be used, which is the default. See https://github.com/googleapis/java-bigquery/blob/v2.34.0/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java#L98-L111 For example, the following create a connection with optional job creation: DriverManager.getConnection( "jdbc:BQDriver:my-project?jobcreationmode=JOB_CREATION_OPTIONAL", driverProperties); Note that this will cause queries to fail if the provided project does not have stateless queries preview enabled.
7ca2597
to
efef4cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stopped right before the start of the tests
This adds a Java Microbenchmark Harness (JMH) benchmark that compares a small query with and without job creation. Documentation on running the microbenchmark can be found in its class' Javadoc. A small query with job creation takes almost twice as long as one with optional job creation.
Method references need # not .
src/test/java/net/starschema/clouddb/jdbc/ConnectionFromResources.java
Outdated
Show resolved
Hide resolved
I think we have a flaky test:
|
71bc3a9 added a microbenchmark. Here's a representative summary:
Queries with optional jobs are between 1.4x and 2.3x faster than required jobs! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
More can be improved in subsequent commits and are outside the scope of this change.
From
https://cloud.google.com/java/docs/reference/google-cloud-bigquery/2.34.1/com.google.cloud.bigquery.BigQuery
Stateless queries are currently in preview.
This PR introduces support for stateless queries via a new JDBC query parameter. Set
jobcreationmode
to a string that matches one of the standardJobCreationMode
enum values:JOB_CREATION_MODE_UNSPECIFIED
: Unspecified JobCreationMode, defaults toJOB_CREATION_REQUIRED
.JOB_CREATION_REQUIRED
: Default. Job creation is always required.JOB_CREATION_OPTIONAL
: Job creation is optional. Returning immediate results is prioritized. BigQuery will automatically determine if a Job needs to be created. The conditions under which BigQuery can decide to not create a Job are subject to change. If Job creation is required, JOB_CREATION_REQUIRED mode should be used, which is the default.See
https://github.com/googleapis/java-bigquery/blob/v2.34.0/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java#L98-L111
For example, the following create a connection with optional job creation:
Note that this will cause queries to fail if the provided project does not have stateless queries preview enabled.