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 executeSelectAsync and Refactor #2294

Merged
merged 27 commits into from Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1591411
Add executeSelectAsync
prash-mi Sep 27, 2022
6e83662
Add executeSelectAsync
prash-mi Sep 27, 2022
6ea69d5
Add ExecuteSelectResponse
prash-mi Sep 27, 2022
344d34b
Add executeSelectAsync(...) methods
prash-mi Oct 10, 2022
3133ca9
feat: Add executeSelectAsync
prash-mi Oct 10, 2022
3350360
implemented ExecuteSelectResponse Builder
prash-mi Oct 10, 2022
0bee0d3
Refactored executeSelect. Added getExecuteSelectResponse
prash-mi Oct 10, 2022
149242c
marked getExecuteSelectFuture private
prash-mi Oct 10, 2022
24c16fe
marked getExecuteSelectFuture private
prash-mi Oct 10, 2022
a16eb33
Add UT for Async methods
prash-mi Oct 10, 2022
6c1b6ed
Added IT for async methods
prash-mi Oct 10, 2022
031e81a
Removed testFastQueryNullSchema as it is no longer needed
prash-mi Oct 10, 2022
1dda219
removed dryRun calls as now we wait till the job is complete
prash-mi Oct 10, 2022
a420b4e
Added testExecuteSelectAsyncTimeout
prash-mi Oct 10, 2022
81798f4
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Oct 10, 2022
e54dba9
updated getExecuteSelectFuture
prash-mi Oct 11, 2022
b99935b
Merge remote-tracking branch 'origin/async-execute-select-and-refacto…
prash-mi Oct 11, 2022
2c0471d
lint
prash-mi Oct 11, 2022
f54136d
Add getters and setters for BigQuerySQLException
prash-mi Oct 11, 2022
89dc083
Add javadoc for overloaded executeSelectAsync and refactored getExecu…
prash-mi Oct 11, 2022
ffa218a
Marked ResultSet and BQSQLException optional
prash-mi Oct 11, 2022
89b29b9
minor refactor: getExecuteSelectFuture
prash-mi Oct 11, 2022
896b476
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Oct 11, 2022
53029f1
Merge branch 'master' into async-execute-select-and-refactor
prash-mi Oct 11, 2022
429101b
Merge remote-tracking branch 'origin/async-execute-select-and-refacto…
prash-mi Oct 11, 2022
704ec9d
update getExecuteSelectFuture
prash-mi Oct 11, 2022
cba789e
update javadoc
prash-mi Oct 11, 2022
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
12 changes: 11 additions & 1 deletion google-cloud-bigquery/clirr-ignored-differences.xml
Expand Up @@ -24,4 +24,14 @@
<className>com/google/cloud/bigquery/RoutineInfo*</className>
<method>*RemoteFunctionOptions(*)</method>
</difference>
</differences>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/bigquery/Connection</className>
<method>com.google.common.util.concurrent.ListenableFuture executeSelectAsync(java.lang.String)</method>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/bigquery/Connection</className>
<method>com.google.common.util.concurrent.ListenableFuture executeSelectAsync(java.lang.String, java.util.List, java.util.Map[])</method>
</difference>
</differences>
Expand Up @@ -17,6 +17,7 @@
package com.google.cloud.bigquery;

import com.google.api.core.BetaApi;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -89,4 +90,103 @@ public interface Connection {
BigQueryResult executeSelect(
String sql, List<Parameter> parameters, Map<String, String>... labels)
throws BigQuerySQLException;

/**
* Execute a SQL statement that returns a single ResultSet and returns a ListenableFuture to
* process the response asynchronously.
*
* <p>Example of running a query.
*
* <pre>
* {
* &#64;code
* ConnectionSettings connectionSettings =
* ConnectionSettings.newBuilder()
* .setUseReadAPI(true)
* .build();
* Connection connection = bigquery.createConnection(connectionSettings);
* String selectQuery = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;";
* ListenableFuture<ExecuteSelectResponse> executeSelectFuture = connection.executeSelectAsync(selectQuery);
* ExecuteSelectResponse executeSelectRes = executeSelectFuture.get();
*
* if(!executeSelectRes.getIsSuccessful()){
* throw executeSelectRes.getBigQuerySQLException();
* }
*
* BigQueryResult bigQueryResult = executeSelectRes.getBigQueryResult();
* ResultSet rs = bigQueryResult.getResultSet();
* while (rs.next()) {
* System.out.println(rs.getString(1));
* }
*
* </pre>
*
* @param sql a static SQL SELECT statement
* @return a ListenableFuture that is used to get the data produced by the query
* @throws BigQuerySQLException upon failure
*/
@BetaApi
ListenableFuture<ExecuteSelectResponse> executeSelectAsync(String sql)
throws BigQuerySQLException;

/**
* Execute a SQL statement that returns a single ResultSet and returns a ListenableFuture to
* process the response asynchronously.
*
* <p>Example of running a query.
*
* <pre>
* {
* &#64;code
* ConnectionSettings connectionSettings =
* ConnectionSettings.newBuilder()
* ..setUseReadAPI(true)
* .build();
* Connection connection = bigquery.createConnection(connectionSettings);
* String selectQuery =
* "SELECT TimestampField, StringField, BooleanField FROM "
* + MY_TABLE
* + " WHERE StringField = @stringParam"
* + " AND IntegerField IN UNNEST(@integerList)";
* QueryParameterValue stringParameter = QueryParameterValue.string("stringValue");
* QueryParameterValue intArrayParameter =
* QueryParameterValue.array(new Integer[] {3, 4}, Integer.class);
* Parameter stringParam =
* Parameter.newBuilder().setName("stringParam").setValue(stringParameter).build();
* Parameter intArrayParam =
* Parameter.newBuilder().setName("integerList").setValue(intArrayParameter).build();
* List<Parameter> parameters = ImmutableList.of(stringParam, intArrayParam);
*
* ListenableFuture<ExecuteSelectResponse> executeSelectFut =
* connection.executeSelectAsync(selectQuery, parameters);
* ExecuteSelectResponse executeSelectRes = executeSelectFuture.get();
*
* if(!executeSelectRes.getIsSuccessful()){
* throw executeSelectRes.getBigQuerySQLException();
* }
*
* BigQueryResult bigQueryResult = executeSelectRes.getBigQueryResult();
* ResultSet rs = bigQueryResult.getResultSet();
* while (rs.next()) {
* System.out.println(rs.getString(1));
* }
*
* </pre>
*
* @param sql SQL SELECT query
* @param parameters named or positional parameters. The set of query parameters must either be
* all positional or all named parameters.
* @param labels (optional) the labels associated with this query. You can use these to organize
* and group your query jobs. Label keys and values can be no longer than 63 characters, can
* only contain lowercase letters, numeric characters, underscores and dashes. International
* characters are allowed. Label values are optional and Label is a Varargs. You should pass
* all the Labels in a single Map .Label keys must start with a letter and each label in the
* list must have a different key.
* @return a ListenableFuture that is used to get the data produced by the query
* @throws BigQuerySQLException upon failure
*/
@BetaApi
ListenableFuture<ExecuteSelectResponse> executeSelectAsync(
String sql, List<Parameter> parameters, Map<String, String>... labels)
throws BigQuerySQLException;
}