Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit80fa478

Browse files
feat: Add executeSelectAsync and Refactor (#2294)
* Add executeSelectAsync* Add executeSelectAsync* Add ExecuteSelectResponse* Add executeSelectAsync(...) methods* feat: Add executeSelectAsync* implemented ExecuteSelectResponse Builder* Refactored executeSelect. Added getExecuteSelectResponse* marked getExecuteSelectFuture private* marked getExecuteSelectFuture private* Add UT for Async methods* Added IT for async methods* Removed testFastQueryNullSchema as it is no longer needed* removed dryRun calls as now we wait till the job is complete* Added testExecuteSelectAsyncTimeout* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md* updated getExecuteSelectFuture* lint* Add getters and setters for BigQuerySQLException* Add javadoc for overloaded executeSelectAsync and refactored getExecuteSelectFuture to handle BigQuerySQLException* Marked ResultSet and BQSQLException optional* minor refactor: getExecuteSelectFuture* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md* update getExecuteSelectFuture* update javadocCo-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent827e5e7 commit80fa478

File tree

6 files changed

+613
-93
lines changed

6 files changed

+613
-93
lines changed

‎google-cloud-bigquery/clirr-ignored-differences.xml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@
2424
<className>com/google/cloud/bigquery/RoutineInfo*</className>
2525
<method>*RemoteFunctionOptions(*)</method>
2626
</difference>
27-
</differences>
27+
<difference>
28+
<differenceType>7012</differenceType>
29+
<className>com/google/cloud/bigquery/Connection</className>
30+
<method>com.google.common.util.concurrent.ListenableFuture executeSelectAsync(java.lang.String)</method>
31+
</difference>
32+
<difference>
33+
<differenceType>7012</differenceType>
34+
<className>com/google/cloud/bigquery/Connection</className>
35+
<method>com.google.common.util.concurrent.ListenableFuture executeSelectAsync(java.lang.String, java.util.List, java.util.Map[])</method>
36+
</difference>
37+
</differences>

‎google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Connection.java‎

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
packagecom.google.cloud.bigquery;
1818

1919
importcom.google.api.core.BetaApi;
20+
importcom.google.common.util.concurrent.ListenableFuture;
2021
importjava.util.List;
2122
importjava.util.Map;
2223

@@ -89,4 +90,103 @@ public interface Connection {
8990
BigQueryResultexecuteSelect(
9091
Stringsql,List<Parameter>parameters,Map<String,String>...labels)
9192
throwsBigQuerySQLException;
93+
94+
/**
95+
* Execute a SQL statement that returns a single ResultSet and returns a ListenableFuture to
96+
* process the response asynchronously.
97+
*
98+
* <p>Example of running a query.
99+
*
100+
* <pre>
101+
* {
102+
* &#64;code
103+
* ConnectionSettings connectionSettings =
104+
* ConnectionSettings.newBuilder()
105+
* .setUseReadAPI(true)
106+
* .build();
107+
* Connection connection = bigquery.createConnection(connectionSettings);
108+
* String selectQuery = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;";
109+
* ListenableFuture<ExecuteSelectResponse> executeSelectFuture = connection.executeSelectAsync(selectQuery);
110+
* ExecuteSelectResponse executeSelectRes = executeSelectFuture.get();
111+
*
112+
* if(!executeSelectRes.getIsSuccessful()){
113+
* throw executeSelectRes.getBigQuerySQLException();
114+
* }
115+
*
116+
* BigQueryResult bigQueryResult = executeSelectRes.getBigQueryResult();
117+
* ResultSet rs = bigQueryResult.getResultSet();
118+
* while (rs.next()) {
119+
* System.out.println(rs.getString(1));
120+
* }
121+
*
122+
* </pre>
123+
*
124+
* @param sql a static SQL SELECT statement
125+
* @return a ListenableFuture that is used to get the data produced by the query
126+
* @throws BigQuerySQLException upon failure
127+
*/
128+
@BetaApi
129+
ListenableFuture<ExecuteSelectResponse>executeSelectAsync(Stringsql)
130+
throwsBigQuerySQLException;
131+
132+
/**
133+
* Execute a SQL statement that returns a single ResultSet and returns a ListenableFuture to
134+
* process the response asynchronously.
135+
*
136+
* <p>Example of running a query.
137+
*
138+
* <pre>
139+
* {
140+
* &#64;code
141+
* ConnectionSettings connectionSettings =
142+
* ConnectionSettings.newBuilder()
143+
* ..setUseReadAPI(true)
144+
* .build();
145+
* Connection connection = bigquery.createConnection(connectionSettings);
146+
* String selectQuery =
147+
* "SELECT TimestampField, StringField, BooleanField FROM "
148+
* + MY_TABLE
149+
* + " WHERE StringField = @stringParam"
150+
* + " AND IntegerField IN UNNEST(@integerList)";
151+
* QueryParameterValue stringParameter = QueryParameterValue.string("stringValue");
152+
* QueryParameterValue intArrayParameter =
153+
* QueryParameterValue.array(new Integer[] {3, 4}, Integer.class);
154+
* Parameter stringParam =
155+
* Parameter.newBuilder().setName("stringParam").setValue(stringParameter).build();
156+
* Parameter intArrayParam =
157+
* Parameter.newBuilder().setName("integerList").setValue(intArrayParameter).build();
158+
* List<Parameter> parameters = ImmutableList.of(stringParam, intArrayParam);
159+
*
160+
* ListenableFuture<ExecuteSelectResponse> executeSelectFut =
161+
* connection.executeSelectAsync(selectQuery, parameters);
162+
* ExecuteSelectResponse executeSelectRes = executeSelectFuture.get();
163+
*
164+
* if(!executeSelectRes.getIsSuccessful()){
165+
* throw executeSelectRes.getBigQuerySQLException();
166+
* }
167+
*
168+
* BigQueryResult bigQueryResult = executeSelectRes.getBigQueryResult();
169+
* ResultSet rs = bigQueryResult.getResultSet();
170+
* while (rs.next()) {
171+
* System.out.println(rs.getString(1));
172+
* }
173+
*
174+
* </pre>
175+
*
176+
* @param sql SQL SELECT query
177+
* @param parameters named or positional parameters. The set of query parameters must either be
178+
* all positional or all named parameters.
179+
* @param labels (optional) the labels associated with this query. You can use these to organize
180+
* and group your query jobs. Label keys and values can be no longer than 63 characters, can
181+
* only contain lowercase letters, numeric characters, underscores and dashes. International
182+
* characters are allowed. Label values are optional and Label is a Varargs. You should pass
183+
* all the Labels in a single Map .Label keys must start with a letter and each label in the
184+
* list must have a different key.
185+
* @return a ListenableFuture that is used to get the data produced by the query
186+
* @throws BigQuerySQLException upon failure
187+
*/
188+
@BetaApi
189+
ListenableFuture<ExecuteSelectResponse>executeSelectAsync(
190+
Stringsql,List<Parameter>parameters,Map<String,String>...labels)
191+
throwsBigQuerySQLException;
92192
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp