@@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file
2222<dependency >
2323 <groupId >com.google.cloud</groupId >
2424 <artifactId >google-cloud-bigquery</artifactId >
25- <version >0.25 .0-beta</version >
25+ <version >0.24 .0-beta</version >
2626</dependency >
2727```
2828If you are using Gradle, add this to your dependencies
2929``` Groovy
30- compile 'com.google.cloud:google-cloud-bigquery:0.25 .0-beta'
30+ compile 'com.google.cloud:google-cloud-bigquery:0.24 .0-beta'
3131```
3232If you are using SBT, add this to your dependencies
3333``` Scala
34- libraryDependencies += " com.google.cloud" % " google-cloud-bigquery" % " 0.25 .0-beta"
34+ libraryDependencies += " com.google.cloud" % " google-cloud-bigquery" % " 0.24 .0-beta"
3535```
3636
3737Example Application
@@ -125,7 +125,7 @@ Then add the following code to create the table:
125125``` java
126126TableId tableId = TableId . of(datasetId, " my_table_id" );
127127// Table field definition
128- Field stringField = Field . of(" StringField" , LegacySQLTypeName . STRING );
128+ Field stringField = Field . of(" StringField" , Field . Type . string() );
129129// Table schema definition
130130Schema schema = Schema . of(stringField);
131131// Create a table
@@ -172,7 +172,7 @@ for the result. Add the following imports at the top of your file:
172172
173173``` java
174174import com.google.cloud.bigquery.FieldValue ;
175- import com.google.cloud.bigquery.QueryJobConfiguration ;
175+ import com.google.cloud.bigquery.QueryRequest ;
176176import com.google.cloud.bigquery.QueryResponse ;
177177
178178import java.util.Iterator ;
@@ -182,17 +182,22 @@ Then add the following code to run the query and wait for the result:
182182
183183``` java
184184// Create a query request
185- QueryJobConfiguration queryConfig =
186- QueryJobConfiguration . of(" SELECT * FROM my_dataset_id.my_table_id" );
185+ QueryRequest queryRequest =
186+ QueryRequest . newBuilder(" SELECT * FROM my_dataset_id.my_table_id" )
187+ .setMaxWaitTime(60000L )
188+ .setPageSize(1000L )
189+ .build();
187190// Request query to be executed and wait for results
188- QueryResponse queryResponse = bigquery. query(
189- queryConfig,
190- QueryOption . of(QueryResultsOption . maxWaitTime(60000L )),
191- QueryOption . of(QueryResultsOption . pageSize(1000L )));
191+ QueryResponse queryResponse = bigquery. query(queryRequest);
192+ while (! queryResponse. jobCompleted()) {
193+ Thread . sleep(1000L );
194+ queryResponse = bigquery. getQueryResults(queryResponse. getJobId());
195+ }
192196// Read rows
197+ Iterator<List<FieldValue > > rowIterator = queryResponse. getResult(). iterateAll();
193198System . out. println(" Table rows:" );
194- for ( FieldValues row : queryResponse . getResult() . iterateAll ()) {
195- System . out. println(row );
199+ while (rowIterator . hasNext ()) {
200+ System . out. println(rowIterator . next() );
196201}
197202```
198203#### Complete source code
0 commit comments