@@ -98,25 +98,23 @@ bigquery.create(DatasetInfo.builder(datasetId).build());
9898
9999#### Creating a table
100100With BigQuery you can create different types of tables: normal tables with an associated schema,
101- external tables backed by data stored on Google Cloud Storage and view tables that are created from
102- a BigQuery SQL query. In this code snippet we show how to create a normal table with only one string
103- field. Add the following imports at the top of your file:
101+ external tables backed by data stored on [ Google Cloud Storage] [ cloud-storage ] and view tables that
102+ are created from a BigQuery SQL query. In this code snippet we show how to create a normal table
103+ with only one string field. Add the following imports at the top of your file:
104104
105105``` java
106+ import com.google.gcloud.bigquery.BaseTableInfo ;
106107import com.google.gcloud.bigquery.Field ;
107108import com.google.gcloud.bigquery.Schema ;
108109import com.google.gcloud.bigquery.TableId ;
109- import com.google.gcloud.bigquery.BaseTableInfo ;
110110import com.google.gcloud.bigquery.TableInfo ;
111111```
112112Then add the following code to create the table:
113113
114114``` java
115115TableId tableId = TableId . of(datasetId, " my_table_id" );
116116// Table field definition
117- Field stringField = Field . builder(" StringField" , Field . Type . string())
118- .mode(Field . Mode . NULLABLE )
119- .build();
117+ Field stringField = Field . of(" StringField" , Field . Type . string());
120118// Table schema definition
121119Schema schema = Schema . of(stringField);
122120// Create a table
@@ -172,14 +170,15 @@ Then add the following code to run the query and wait for the result:
172170
173171``` java
174172// Create a query request
175- QueryRequest queryRequest = QueryRequest . builder(" SELECT * FROM my_dataset_id.my_table_id" )
176- .maxWaitTime(60000L )
177- .maxResults(1000L )
178- .build();
173+ QueryRequest queryRequest =
174+ QueryRequest . builder(" SELECT * FROM my_dataset_id.my_table_id" )
175+ .maxWaitTime(60000L )
176+ .maxResults(1000L )
177+ .build();
179178// Request query to be executed and wait for results
180179QueryResponse queryResponse = bigquery. query(queryRequest);
181180while (! queryResponse. jobComplete()) {
182- Thread . sleep(1000 );
181+ Thread . sleep(1000L );
183182 queryResponse = bigquery. getQueryResults(queryResponse. jobId());
184183}
185184// Read rows
@@ -229,9 +228,7 @@ public class GcloudBigQueryExample {
229228
230229 TableId tableId = TableId . of(datasetId, " my_table_id" );
231230 // Table field definition
232- Field stringField = Field . builder(" StringField" , Field . Type . string())
233- .mode(Field . Mode . NULLABLE )
234- .build();
231+ Field stringField = Field . of(" StringField" , Field . Type . string());
235232 // Table schema definition
236233 Schema schema = Schema . of(stringField);
237234 // Create a table
@@ -255,14 +252,15 @@ public class GcloudBigQueryExample {
255252 }
256253
257254 // Create a query request
258- QueryRequest queryRequest = QueryRequest . builder(" SELECT * FROM my_dataset_id.my_table_id" )
259- .maxWaitTime(60000L )
260- .maxResults(1000L )
261- .build();
255+ QueryRequest queryRequest =
256+ QueryRequest . builder(" SELECT * FROM my_dataset_id.my_table_id" )
257+ .maxWaitTime(60000L )
258+ .maxResults(1000L )
259+ .build();
262260 // Request query to be executed and wait for results
263261 QueryResponse queryResponse = bigquery. query(queryRequest);
264262 while (! queryResponse. jobComplete()) {
265- Thread . sleep(1000 );
263+ Thread . sleep(1000L );
266264 queryResponse = bigquery. getQueryResults(queryResponse. jobId());
267265 }
268266 // Read rows
@@ -275,6 +273,11 @@ public class GcloudBigQueryExample {
275273}
276274```
277275
276+ Troubleshooting
277+ ---------------
278+
279+ To get help, follow the ` gcloud-java ` links in the ` gcloud-* ` [ shared Troubleshooting document] ( https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting ) .
280+
278281Java Versions
279282-------------
280283
@@ -315,4 +318,5 @@ Apache 2.0 - See [LICENSE] for more information.
315318[ cloud-platform ] : https://cloud.google.com/
316319
317320[ cloud-bigquery ] : https://cloud.google.com/bigquery/
321+ [ cloud-storage ] : https://cloud.google.com/storage/
318322[ bigquery-api ] : http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/bigquery/package-summary.html
0 commit comments