From b45ca43a6af62d1ff41fe2c899d5102c8393db35 Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Thu, 23 Apr 2020 15:42:08 -0400 Subject: [PATCH] chore: update README to use autosynth (#290) --- .readme-partials.yaml | 104 +++++++++++++++ .repo-metadata.json | 6 +- README.md | 257 ++++++++++++++++++++++--------------- samples/snippets/README.md | 48 ------- synth.metadata | 7 +- synth.py | 1 - 6 files changed, 265 insertions(+), 158 deletions(-) create mode 100644 .readme-partials.yaml delete mode 100644 samples/snippets/README.md diff --git a/.readme-partials.yaml b/.readme-partials.yaml new file mode 100644 index 000000000..47f096060 --- /dev/null +++ b/.readme-partials.yaml @@ -0,0 +1,104 @@ +custom_content: | + #### 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. \ No newline at end of file diff --git a/.repo-metadata.json b/.repo-metadata.json index 3db81c9ae..2db55ce3d 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -1,13 +1,15 @@ { "name": "bigquery", - "name_pretty": "BigQuery", + "name_pretty": "Cloud BigQuery", "product_documentation": "https://cloud.google.com/bigquery", "client_documentation": "https://googleapis.dev/java/google-cloud-bigquery/latest", + "api_description": "is a fully managed, NoOps, low cost data analytics service.\nData can be streamed into BigQuery at millions of rows per second to enable real-time analysis.\nWith BigQuery you can easily deploy Petabyte-scale Databases.", "issue_tracker": "https://issuetracker.google.com/savedsearches/559654", "release_level": "ga", "language": "java", "repo": "googleapis/java-bigquery", "repo_short": "java-bigquery", "distribution_name": "com.google.cloud:google-cloud-bigquery", - "api_id": "bigquery.googleapis.com" + "api_id": "bigquery.googleapis.com", + "requires_billing": true } diff --git a/README.md b/README.md index ee3ddbd5f..06e800ecf 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,52 @@ -Google Cloud Java Client for BigQuery -==================================== +# Google Cloud BigQuery Client for Java -Java idiomatic client for [Google Cloud BigQuery][cloud-bigquery]. +Java idiomatic client for [Cloud BigQuery][product-docs]. -[![Kokoro CI](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.svg)](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.html) -[![Maven](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquery.svg)]( https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquery.svg) -[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/google-cloud-java) +[![Maven][maven-version-image]][maven-version-link] +![Stability][stability-image] -- [Product Documentation][bigquery-product-docs] -- [Client Library Documentation][bigquery-client-lib-docs] +- [Product Documentation][product-docs] +- [Client Library Documentation][javadocs] -Quickstart ----------- -If you are using Maven with a BOM, add this to your pom.xml file. +## Quickstart + +If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file ```xml + - - - com.google.cloud - libraries-bom - 3.3.0 - pom - import - - - - + + + com.google.cloud + libraries-bom + 5.1.0 + pom + import + + + + + - com.google.cloud - google-cloud-bigquery + com.google.cloud + google-cloud-bigquery + ``` -[//]: # ({x-version-update-start:google-cloud-bigquery:released}) -If you are using Maven without a BOM, add this to your dependencies. + +If you are using Maven without BOM, add this to your dependencies: + ```xml com.google.cloud google-cloud-bigquery 1.111.1 + ``` + +[//]: # ({x-version-update-start:google-cloud-bigquery:released}) + If you are using Gradle, add this to your dependencies ```Groovy compile 'com.google.cloud:google-cloud-bigquery:1.111.1' @@ -50,57 +57,35 @@ libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "1.111.1" ``` [//]: # ({x-version-update-end}) -Authentication --------------- +## Authentication -See the [Authentication](https://github.com/googleapis/google-cloud-java#authentication) section in the base directory's README. +See the [Authentication][authentication] section in the base directory's README. -About Google Cloud BigQuery --------------------------- +## Getting Started -[Google Cloud BigQuery][cloud-bigquery] is a fully managed, NoOps, low cost data analytics service. -Data can be streamed into BigQuery at millions of rows per second to enable real-time analysis. -With BigQuery you can easily deploy Petabyte-scale Databases. +### Prerequisites -Be sure to activate the Google Cloud BigQuery API on the Developer's Console to use BigQuery from -your project. - -See the [BigQuery client library docs][bigquery-client-lib-docs] to learn how to interact -with Google Cloud BigQuery using this Client Library. - -Getting Started ---------------- -#### Prerequisites -For this tutorial, you will need a -[Google Developers Console](https://console.developers.google.com/) project with the BigQuery API -enabled. You will need to [enable billing](https://support.google.com/cloud/answer/6158867?hl=en) to -use Google Cloud BigQuery. -[Follow these instructions](https://cloud.google.com/resource-manager/docs/creating-managing-projects) to get your -project set up. You will also need to set up the local development environment by [installing the -Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands in command line: +You will need a [Google Cloud Platform Console][developer-console] project with the Cloud BigQuery [API enabled][enable-api]. +You will need to [enable billing][enable-billing] to use Google Cloud BigQuery. +[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by +[installing the Google Cloud SDK][cloud-sdk] and running the following commands in command line: `gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`. -#### Installation and setup +### Installation and setup + You'll need to obtain the `google-cloud-bigquery` library. See the [Quickstart](#quickstart) section to add `google-cloud-bigquery` as a dependency in your code. -#### Creating an authorized service object -To make authenticated requests to Google Cloud BigQuery, you must create a service object with -credentials. You can then make API calls by calling methods on the BigQuery service object. The -simplest way to authenticate is to use -[Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials). -These credentials are automatically inferred from your environment, so you only need the following -code to create your service object: +## About Cloud BigQuery -```java -import com.google.cloud.bigquery.BigQuery; -import com.google.cloud.bigquery.BigQueryOptions; -BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); -``` +[Cloud BigQuery][product-docs] is a fully managed, NoOps, low cost data analytics service. +Data can be streamed into BigQuery at millions of rows per second to enable real-time analysis. +With BigQuery you can easily deploy Petabyte-scale Databases. + +See the [Cloud BigQuery client library docs][javadocs] to learn how to +use this Cloud BigQuery Client Library. -For other authentication options, see the -[Authentication](https://github.com/googleapis/google-cloud-java#authentication) page. #### Creating a dataset With BigQuery you can create datasets. A dataset is a grouping mechanism that holds zero or more @@ -119,7 +104,7 @@ 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][cloud-storage] and view tables that +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: @@ -206,53 +191,119 @@ running on Compute Engine or from your own desktop. To run the example on App En the code from the main method to your application's servlet class and change the print statements to display on your webpage. -Troubleshooting ---------------- -To get help, follow the instructions in the [shared Troubleshooting document](https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting). -Transport ---------- -BigQuery uses HTTP for the transport layer. - -Java Versions -------------- +## Samples + +Samples are in the [`samples/`](https://github.com/googleapis/java-bigquery/tree/master/samples) directory. The samples' `README.md` +has instructions for running the samples. + +| Sample | Source Code | Try it | +| --------------------------- | --------------------------------- | ------ | +| Add Column Load Append | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/AddColumnLoadAppend.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/AddColumnLoadAppend.java) | +| Add Empty Column | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/AddEmptyColumn.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/AddEmptyColumn.java) | +| Auth Drive Scope | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/AuthDriveScope.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/AuthDriveScope.java) | +| Auth Snippets | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/AuthSnippets.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/AuthSnippets.java) | +| Copy Multiple Tables | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/CopyMultipleTables.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/CopyMultipleTables.java) | +| Create Clustered Table | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/CreateClusteredTable.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/CreateClusteredTable.java) | +| Create Dataset | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/CreateDataset.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/CreateDataset.java) | +| Create Partitioned Table | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/CreatePartitionedTable.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/CreatePartitionedTable.java) | +| Create Table | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/CreateTable.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/CreateTable.java) | +| Delete Dataset | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/DeleteDataset.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/DeleteDataset.java) | +| Delete Table | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/DeleteTable.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/DeleteTable.java) | +| Extract Table To Json | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToJson.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/ExtractTableToJson.java) | +| Get Dataset Info | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/GetDatasetInfo.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/GetDatasetInfo.java) | +| Get Model | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/GetModel.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/GetModel.java) | +| Get Table | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/GetTable.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/GetTable.java) | +| List Datasets | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/ListDatasets.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/ListDatasets.java) | +| List Models | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/ListModels.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/ListModels.java) | +| List Tables | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/ListTables.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/ListTables.java) | +| Load Local File | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/LoadLocalFile.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/LoadLocalFile.java) | +| Load Parquet | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/LoadParquet.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/LoadParquet.java) | +| Load Parquet Replace Table | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/LoadParquetReplaceTable.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/LoadParquetReplaceTable.java) | +| Load Partitioned Table | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/LoadPartitionedTable.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/LoadPartitionedTable.java) | +| Load Table Clustered | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/LoadTableClustered.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/LoadTableClustered.java) | +| Nested Repeated Schema | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/NestedRepeatedSchema.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/NestedRepeatedSchema.java) | +| Query Clustered Table | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/QueryClusteredTable.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/QueryClusteredTable.java) | +| Query With Named Parameters | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/QueryWithNamedParameters.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/QueryWithNamedParameters.java) | +| Query With Positional Parameters | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/QueryWithPositionalParameters.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/QueryWithPositionalParameters.java) | +| 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) | +| 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 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) | +| Simple App | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/SimpleApp.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/SimpleApp.java) | +| Table Insert Rows | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/TableInsertRows.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/TableInsertRows.java) | +| Update Dataset Access | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/UpdateDatasetAccess.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/UpdateDatasetAccess.java) | +| Update Dataset Description | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/UpdateDatasetDescription.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/UpdateDatasetDescription.java) | +| Update Dataset Expiration | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/UpdateDatasetExpiration.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/UpdateDatasetExpiration.java) | +| Update Table Expiration | [source code](https://github.com/googleapis/java-bigquery/blob/master/samples/snippets/src/main/java/com/example/bigquery/UpdateTableExpiration.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/UpdateTableExpiration.java) | + + + +## Troubleshooting + +To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting]. + +## Java Versions Java 7 or above is required for using this client. -Testing -------- - -This library has tools to help make tests for code using Cloud BigQuery. - -See [TESTING] to read more about testing. +## Versioning -Versioning ----------- This library follows [Semantic Versioning](http://semver.org/). -It is currently in major version one (``1.y.z``), which means that the public API should be considered stable. -Contributing ------------- +## Contributing -Contributions to this library are always welcome and highly encouraged. - -See [CONTRIBUTING] for more information on how to get started. - -License -------- -Apache 2.0 - See [LICENSE] for more information. - - -[CONTRIBUTING]:https://github.com/googleapis/google-cloud-java/blob/master/CONTRIBUTING.md -[LICENSE]: https://github.com/googleapis/google-cloud-java/blob/master/LICENSE -[TESTING]: https://github.com/googleapis/google-cloud-java/blob/master/TESTING.md#testing-code-that-uses-bigquery -[cloud-platform]: https://cloud.google.com/ +Contributions to this library are always welcome and highly encouraged. -[cloud-bigquery]: https://cloud.google.com/bigquery/ -[cloud-storage]: https://cloud.google.com/storage/ -[bigquery-product-docs]: https://cloud.google.com/bigquery/docs/ -[bigquery-client-lib-docs]: https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/bigquery/package-summary.html +See [CONTRIBUTING][contributing] for more information how to get started. + +Please note that this project is released with a Contributor Code of Conduct. By participating in +this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more +information. + +## License + +Apache 2.0 - See [LICENSE][license] for more information. + +## CI Status + +Java Version | Status +------------ | ------ +Java 7 | [![Kokoro CI][kokoro-badge-image-1]][kokoro-badge-link-1] +Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2] +Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3] +Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4] +Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5] + +[product-docs]: https://cloud.google.com/bigquery +[javadocs]: https://googleapis.dev/java/google-cloud-bigquery/latest +[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java7.svg +[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java7.html +[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java8.svg +[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java8.html +[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java8-osx.svg +[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java8-osx.html +[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java8-win.svg +[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java8-win.html +[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java11.svg +[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java11.html +[stability-image]: https://img.shields.io/badge/stability-ga-green +[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquery.svg +[maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-bigquery&core=gav +[authentication]: https://github.com/googleapis/google-cloud-java#authentication +[developer-console]: https://console.developers.google.com/ +[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects +[cloud-sdk]: https://cloud.google.com/sdk/ +[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting +[contributing]: https://github.com/googleapis/java-bigquery/blob/master/CONTRIBUTING.md +[code-of-conduct]: https://github.com/googleapis/java-bigquery/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct +[license]: https://github.com/googleapis/java-bigquery/blob/master/LICENSE +[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing +[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=bigquery.googleapis.com +[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png diff --git a/samples/snippets/README.md b/samples/snippets/README.md deleted file mode 100644 index b1988a7f8..000000000 --- a/samples/snippets/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# Getting Started with BigQuery and the Google Java API Client library - - -Open in Cloud Shell - -[Google's BigQuery Service][BigQuery] features a REST-based API that allows -developers to create applications to run ad-hoc queries on massive datasets. -These sample Java applications demonstrate how to access the BigQuery API using -the [Google Cloud Client Library for Java][google-cloud-java]. - -[BigQuery]: https://cloud.google.com/bigquery/ -[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java - -## Quickstart - -Install [Maven](http://maven.apache.org/). - -[Authenticate using a service account](https://cloud.google.com/docs/authentication/getting-started). -Create a service account, download a JSON key file, and set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. - -Build your project with: - - mvn clean package -DskipTests - -You can then run a given `ClassName` via: - - mvn exec:java -Dexec.mainClass=com.example.bigquery.ClassName \ - -DpropertyName=propertyValue \ - -Dexec.args="any arguments to the app" - -### Creating a new dataset (using the quickstart sample) - - mvn exec:java -Dexec.mainClass=com.example.bigquery.QuickstartSample - -### Running a query using standard SQL syntax - - mvn exec:java -Dexec.mainClass=com.example.bigquery.QuerySample \ - -Dexec.args=' \ - --query="SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;" \ - --runStandardSqlQuery' - -### Running the simple app example - -To run the example from the [simple app example -documentation](https://cloud.google.com/bigquery/create-simple-app-api): - - mvn exec:java -Dexec.mainClass=com.example.bigquery.SimpleApp - diff --git a/synth.metadata b/synth.metadata index 4a018664a..c252ca41b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,16 +3,15 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/java-bigquery.git", - "sha": "9ec561d13f66a3215f313b1848b144f4feec767b" + "remote": "git@github.com:stephaniewang526/java-bigquery.git", + "sha": "5992b8f263aefadb05a8e9f382374deea655f503" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "85cbc7f954f4c4c3534f0caafbaed22a8f80f602", - "log": "85cbc7f954f4c4c3534f0caafbaed22a8f80f602\nfix: use https vcs install for python-test-utils (#492)\n\n\n52638600f387deb98efb5f9c85fec39e82aa9052\nbuild(java): set GOOGLE_CLOUD_PROJECT env for samples/integration tests (#484)\n\n* build(java): set GOOGLE_CLOUD_PROJECT env variable for samples/integration tests\n\n* ci: use java-docs-samples-testing for sample tests\n3df869dd6eb546ef13beeb7a9efa6ee0226afafd\nci: add dependency list completeness check (#490)\n\n\n682c0c37d1054966ca662a44259e96cc7aea4413\nbuild(nodejs): update lint ignore rules (#488)\n\n\n97c7ccfdceb927db1cbe6f3bb09616aa02bafd89\ndoc: document context-aware commit flags (#481)\n\nAlso, delete obsolete blurb about cleaning up old, dead files.\n\nCo-authored-by: Jeff Ching \n8eff3790f88b50706a0c4b6a20b385f24e9ac4e7\nfeat: common postprocessing for node libraries (#485)\n\nCo-authored-by: Justin Beckwith \n21c3b57ae54ae9db6a3a6b48b31c970c6ab56f19\nbuild(nodejs): remove unused codecov config (#486)\n\n\n6f32150677c9784f3c3a7e1949472bd29c9d72c5\nfix: installs test_utils from its common repo (#480)\n\n\n74ce986d3b5431eb66985e9a00c4eb45295a4020\nfix: stop recording update_time in synth.metadata (#478)\n\n\n7f8e62aa3edd225f76347a16f92e400661fdfb52\nchore(java): release-please only updates non maven versions in README (#476)\n\nPrevent release-please and synthtool from fighting over the released library version. Synthtool updates the install snippets from the samples pom.xml files so the bots fight if they are temporarily out of sync after a release.\nc7e0e517d7f46f77bebd27da2e5afcaa6eee7e25\nbuild(java): fix nightly integration test config to run integrations (#465)\n\nThis was only running the units.\nbd69a2aa7b70875f3c988e269706b22fefbef40e\nbuild(java): fix retry_with_backoff when -e option set (#475)\n\n\nd9b173c427bfa0c6cca818233562e7e8841a357c\nfix: record version of working repo in synth.metadata (#473)\n\nPartial revert of b37cf74d12e9a42b9de9e61a4f26133d7cd9c168.\nf73a541770d95a609e5be6bf6b3b220d17cefcbe\nfeat(discogapic): allow local discovery-artifact-manager (#474)\n\n\n8cf0f5d93a70c3dcb0b4999d3152c46d4d9264bf\ndoc: describe the Autosynth & Synthtool protocol (#472)\n\n* doc: describe the Autosynth & Synthtool protocol\n\n* Accommodate review comments.\n980baaa738a1ad8fa02b4fdbd56be075ee77ece5\nfix: pin sphinx to <3.0.0 as new version causes new error (#471)\n\nThe error `toctree contains reference to document changlelog that doesn't have a title: no link will be generated` occurs as of 3.0.0. Pinning to 2.x until we address the docs build issue.\n\nTowards #470\n\nI did this manually for python-datastore https://github.com/googleapis/python-datastore/pull/22\n928b2998ac5023e7c7e254ab935f9ef022455aad\nchore(deps): update dependency com.google.cloud.samples:shared-configuration to v1.0.15 (#466)\n\nCo-authored-by: Jeffrey Rennie \n188f1b1d53181f739b98f8aa5d40cfe99eb90c47\nfix: allow local and external deps to be specified (#469)\n\nModify noxfile.py to allow local and external dependencies for\nsystem tests to be specified.\n1df68ed6735ddce6797d0f83641a731c3c3f75b4\nfix: apache license URL (#468)\n\n\nf4a59efa54808c4b958263de87bc666ce41e415f\nfeat: Add discogapic support for GAPICBazel generation (#459)\n\n* feat: Add discogapic support for GAPICBazel generation\n\n* reformat with black\n\n* Rename source repository variable\n\nCo-authored-by: Jeffrey Rennie \n99820243d348191bc9c634f2b48ddf65096285ed\nfix: update template files for Node.js libraries (#463)\n\n\n3cbe6bcd5623139ac9834c43818424ddca5430cb\nfix(ruby): remove dead troubleshooting link from generated auth guide (#462)\n\n\na003d8655d3ebec2bbbd5fc3898e91e152265c67\ndocs: remove \"install stable\" instructions (#461)\n\nThe package hasn't been released to PyPI in some time\nf5e8c88d9870d8aa4eb43fa0b39f07e02bfbe4df\nchore(python): add license headers to config files; make small tweaks to templates (#458)\n\n\n" + "sha": "716f741f2d307b48cbe8a5bc3bc883571212344a" } } ] diff --git a/synth.py b/synth.py index 37ed33679..69d7bf565 100644 --- a/synth.py +++ b/synth.py @@ -19,7 +19,6 @@ AUTOSYNTH_MULTIPLE_COMMITS = True java.common_templates(excludes=[ - 'README.md', '.kokoro/continuous/java8-samples.cfg', '.kokoro/continuous/java11-samples.cfg', '.kokoro/nightly/java8-samples.cfg',