From 1b333a8d46a308bf4f455e301e387821243c3377 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 11 Aug 2020 08:00:44 -0700 Subject: [PATCH] chore: update readme (#668) autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. --- README.md | 104 +------------------------------------------------ synth.metadata | 2 +- 2 files changed, 2 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index a2e9dce59..8edaba3a0 100644 --- a/README.md +++ b/README.md @@ -87,109 +87,6 @@ See the [Cloud BigQuery client library docs][javadocs] to learn how to use this Cloud BigQuery Client Library. -#### Creating a dataset -With BigQuery you can create datasets. A dataset is a grouping mechanism that holds zero or more -tables. Add the following import at the top of your file: - -```java -import com.google.cloud.bigquery.DatasetInfo; -``` -Then, to create the dataset, use the following code: - -```java -// Create a dataset -String datasetId = "my_dataset_id"; -bigquery.create(DatasetInfo.newBuilder(datasetId).build()); -``` - -#### Creating a table -With BigQuery you can create different types of tables: normal tables with an associated schema, -external tables backed by data stored on [Google Cloud Storage](https://cloud.google.com/storage/) and view tables that -are created from a BigQuery SQL query. In this code snippet we show how to create a normal table -with only one string field. Add the following imports at the top of your file: - -```java -import com.google.cloud.bigquery.Field; -import com.google.cloud.bigquery.Schema; -import com.google.cloud.bigquery.StandardTableDefinition; -import com.google.cloud.bigquery.Table; -import com.google.cloud.bigquery.TableId; -import com.google.cloud.bigquery.TableInfo; -``` -Then add the following code to create the table: - -```java -TableId tableId = TableId.of(datasetId, "my_table_id"); -// Table field definition -Field stringField = Field.of("StringField", LegacySQLTypeName.STRING); -// Table schema definition -Schema schema = Schema.of(stringField); -// Create a table -StandardTableDefinition tableDefinition = StandardTableDefinition.of(schema); -Table createdTable = bigquery.create(TableInfo.of(tableId, tableDefinition)); -``` - -#### Loading data into a table -BigQuery provides several ways to load data into a table: streaming rows or loading data from a -Google Cloud Storage file. In this code snippet we show how to stream rows into a table. -Add the following imports at the top of your file: - -```java -import com.google.cloud.bigquery.InsertAllRequest; -import com.google.cloud.bigquery.InsertAllResponse; - -import java.util.HashMap; -import java.util.Map; -``` -Then add the following code to insert data: - -```java -Map firstRow = new HashMap<>(); -Map secondRow = new HashMap<>(); -firstRow.put("StringField", "value1"); -secondRow.put("StringField", "value2"); -// Create an insert request -InsertAllRequest insertRequest = InsertAllRequest.newBuilder(tableId) - .addRow(firstRow) - .addRow(secondRow) - .build(); -// Insert rows -InsertAllResponse insertResponse = bigquery.insertAll(insertRequest); -// Check if errors occurred -if (insertResponse.hasErrors()) { - System.out.println("Errors occurred while inserting rows"); -} -``` - -#### Querying data -BigQuery enables querying data by running queries and waiting for the result. Queries can be run -directly or through a Query Job. In this code snippet we show how to run a query directly and wait -for the result. Add the following imports at the top of your file: - -```java -import com.google.cloud.bigquery.FieldValueList; -import com.google.cloud.bigquery.QueryJobConfiguration; -``` -Then add the following code to run the query and wait for the result: - -```java -// Create a query request -QueryJobConfiguration queryConfig = - QueryJobConfiguration.newBuilder("SELECT my_column FROM my_dataset_id.my_table_id").build(); -// Read rows -System.out.println("Table rows:"); -for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) { - System.out.println(row); -} -``` -#### Complete source code - -In -[InsertDataAndQueryTable.java](https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/snippets/InsertDataAndQueryTable.java) -we put together all the code shown above into one program. The program assumes that you are -running on Compute Engine or from your own desktop. To run the example on App Engine, simply move -the code from the main method to your application's servlet class and change the print statements to -display on your webpage. @@ -294,6 +191,7 @@ has instructions for running the samples. | Query With Structs Parameters | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/QueryWithStructsParameters.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-bigquery&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/bigquery/QueryWithStructsParameters.java) | | Query With Timestamp Parameters | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/QueryWithTimestampParameters.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-bigquery&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/bigquery/QueryWithTimestampParameters.java) | | Quickstart Sample | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/QuickstartSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-bigquery&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/bigquery/QuickstartSample.java) | +| Relax Column Load Append | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/RelaxColumnLoadAppend.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-bigquery&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/bigquery/RelaxColumnLoadAppend.java) | | Relax Column Mode | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/RelaxColumnMode.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-bigquery&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/bigquery/RelaxColumnMode.java) | | Relax Table Query | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/RelaxTableQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-bigquery&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/bigquery/RelaxTableQuery.java) | | Run Legacy Query | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/RunLegacyQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-bigquery&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/bigquery/RunLegacyQuery.java) | diff --git a/synth.metadata b/synth.metadata index 1a2ac3e02..7701b7f7b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-bigquery.git", - "sha": "df3788a2ba9223bd99c56b6e76fbc6b0ab2b302a" + "sha": "349e11163773b22deae3dfb0ed4373f717711b79" } }, {