Skip to content

Commit

Permalink
Merge branch 'main' into revert-176-revert-171-shivane/removeOAuthTok…
Browse files Browse the repository at this point in the history
…enFromQueryParams
  • Loading branch information
goomrw committed Jan 12, 2024
2 parents c2dcf5d + 3ab8355 commit d91f423
Show file tree
Hide file tree
Showing 21 changed files with 1,660 additions and 816 deletions.
40 changes: 37 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
to a groupId that we have ownership over -->
<groupId>com.google.looker-open-source</groupId>
<artifactId>bqjdbc</artifactId>
<version>2.3.30-SNAPSHOT</version>
<version>3.1.0</version>
<name>Big Query over JDBC</name>
<description>A simple JDBC driver, to reach Google's BigQuery</description>
<properties>
Expand Down Expand Up @@ -142,6 +142,18 @@
<version>1.19.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.37</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.37</version>
<scope>test</scope>
</dependency>
<!-- END TEST DEPENDENCIES -->
</dependencies>
<build>
Expand Down Expand Up @@ -218,11 +230,33 @@
<version>1.7</version>
<style>GOOGLE</style>
</googleJavaFormat>
<toggleOffOn />
</java>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>benchmark-stateless-small</id>
<goals><goal>exec</goal></goals>
<configuration>
<classpathScope>test</classpathScope>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.openjdk.jmh.Main</argument>
<argument>
net.starschema.clouddb.jdbc.StatelessSmallQueryBenchmark
</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
44 changes: 44 additions & 0 deletions src/main/java/net/starschema/clouddb/jdbc/BQConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,34 @@ public class BQConnection implements Connection {
/** Boolean to determine whether or not to use legacy sql (default: false) * */
private final boolean useLegacySql;

/**
* Enum that describes whether to create a job in projects that support stateless queries. Copied
* from <a
* href="https://github.com/googleapis/java-bigquery/blob/v2.34.0/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java#L98-L111">google-cloud-bigquery
* 2.34.0</a>
*/
public static enum JobCreationMode {
/** If unspecified JOB_CREATION_REQUIRED is the default. */
JOB_CREATION_MODE_UNSPECIFIED,
/** Default. Job creation is always required. */
JOB_CREATION_REQUIRED,

/**
* 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.
*
* <p>Note that no job ID will be created if the results were returned immediately.
*/
JOB_CREATION_OPTIONAL;

private JobCreationMode() {}
}

/** The job creation mode - */
private JobCreationMode jobCreationMode = JobCreationMode.JOB_CREATION_MODE_UNSPECIFIED;

/** getter for useLegacySql */
public boolean getUseLegacySql() {
return useLegacySql;
Expand Down Expand Up @@ -210,6 +238,18 @@ public BQConnection(String url, Properties loginProp, HttpTransport httpTranspor
this.useQueryCache =
parseBooleanQueryParam(caseInsensitiveProps.getProperty("querycache"), true);

final String jobCreationModeString = caseInsensitiveProps.getProperty("jobcreationmode");
if (jobCreationModeString == null) {
jobCreationMode = null;
} else {
try {
jobCreationMode = JobCreationMode.valueOf(jobCreationModeString);
} catch (IllegalArgumentException e) {
throw new BQSQLException(
"could not parse " + jobCreationModeString + " as job creation mode", e);
}
}

// Create Connection to BigQuery
if (serviceAccount) {
try {
Expand Down Expand Up @@ -1214,4 +1254,8 @@ public Long getMaxBillingBytes() {
public Integer getTimeoutMs() {
return timeoutMs;
}

public JobCreationMode getJobCreationMode() {
return jobCreationMode;
}
}
Loading

0 comments on commit d91f423

Please sign in to comment.