From f26e9cbe4948a2021c045bdd9a089e97d5a56350 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 23 Apr 2020 00:01:40 +0200 Subject: [PATCH 01/12] chore(deps): update dependency com.google.cloud:google-cloud-bigquery to v1.111.1 (#287) --- samples/install-without-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index e7f5b58c26..7c4826a39d 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -45,7 +45,7 @@ com.google.cloud google-cloud-bigquery - 1.111.0 + 1.111.1 From 62f59213a17951352c8873503f0c9c54e60bbfa1 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2020 18:10:51 -0400 Subject: [PATCH 02/12] chore: release 1.111.2-SNAPSHOT (#288) * updated versions.txt [ci skip] * updated samples/install-without-bom/pom.xml [ci skip] * updated samples/pom.xml [ci skip] * updated samples/snippets/pom.xml [ci skip] * updated google-cloud-bigquery/pom.xml [ci skip] * updated pom.xml [ci skip] * updated samples/snapshot/pom.xml [ci skip] Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- google-cloud-bigquery/pom.xml | 4 ++-- pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/google-cloud-bigquery/pom.xml b/google-cloud-bigquery/pom.xml index e091a36bae..89a0af6893 100644 --- a/google-cloud-bigquery/pom.xml +++ b/google-cloud-bigquery/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-bigquery - 1.111.1 + 1.111.2-SNAPSHOT jar BigQuery https://github.com/googleapis/java-bigquery @@ -11,7 +11,7 @@ com.google.cloud google-cloud-bigquery-parent - 1.111.1 + 1.111.2-SNAPSHOT google-cloud-bigquery diff --git a/pom.xml b/pom.xml index 5737664cac..2c7758e037 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-bigquery-parent pom - 1.111.1 + 1.111.2-SNAPSHOT BigQuery Parent https://github.com/googleapis/java-bigquery @@ -116,7 +116,7 @@ com.google.cloud google-cloud-bigquery - 1.111.1 + 1.111.2-SNAPSHOT diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 705ca03e59..0fd14b538f 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -44,7 +44,7 @@ com.google.cloud google-cloud-bigquery - 1.111.1 + 1.111.2-SNAPSHOT diff --git a/versions.txt b/versions.txt index 5a76a3b547..90e08c2797 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-bigquery:1.111.1:1.111.1 \ No newline at end of file +google-cloud-bigquery:1.111.1:1.111.2-SNAPSHOT \ No newline at end of file From 78149a5450052d3bf8b22e09af95f0607e4db5db Mon Sep 17 00:00:00 2001 From: shollyman Date: Thu, 23 Apr 2020 12:21:53 -0700 Subject: [PATCH 03/12] feature: add policy tags support (column ACLs) (#289) * feature: add policy tags support (column ACLs) * code formatter --- .../java/com/google/cloud/bigquery/Field.java | 24 ++++++- .../com/google/cloud/bigquery/PolicyTags.java | 65 +++++++++++++++++++ .../com/google/cloud/bigquery/SchemaTest.java | 5 ++ .../cloud/bigquery/it/ITBigQueryTest.java | 28 ++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/PolicyTags.java diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Field.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Field.java index 8259cc7e7e..1213bc4e8b 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Field.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Field.java @@ -58,6 +58,7 @@ public TableFieldSchema apply(Field field) { private final FieldList subFields; private final String mode; private final String description; + private final PolicyTags policyTags; /** * Mode for a BigQuery Table field. {@link Mode#NULLABLE} fields can be set to {@code null}, @@ -77,6 +78,7 @@ public static final class Builder { private FieldList subFields; private String mode; private String description; + private PolicyTags policyTags; private Builder() {} @@ -86,6 +88,7 @@ private Builder(Field field) { this.subFields = field.subFields; this.mode = field.mode; this.description = field.description; + this.policyTags = field.policyTags; } /** @@ -190,6 +193,12 @@ public Builder setDescription(String description) { return this; } + /** Sets the policy tags for the field. */ + public Builder setPolicyTags(PolicyTags policyTags) { + this.policyTags = policyTags; + return this; + } + /** Creates a {@code Field} object. */ public Field build() { return new Field(this); @@ -202,6 +211,7 @@ private Field(Builder builder) { this.subFields = builder.subFields; this.mode = builder.mode; this.description = builder.description; + this.policyTags = builder.policyTags; } /** Returns the field name. */ @@ -229,6 +239,11 @@ public String getDescription() { return Data.isNull(description) ? null : description; } + /** Returns the policy tags for the field. */ + public PolicyTags getPolicyTags() { + return policyTags; + } + /** * Returns the list of sub-fields if {@link #getType()} is a {@link LegacySQLTypeName#RECORD}. * Returns {@code null} otherwise. @@ -249,12 +264,13 @@ public String toString() { .add("type", type) .add("mode", mode) .add("description", description) + .add("policyTags", policyTags) .toString(); } @Override public int hashCode() { - return Objects.hash(name, type, mode, description); + return Objects.hash(name, type, mode, description, policyTags); } @Override @@ -316,6 +332,9 @@ TableFieldSchema toPb() { if (description != null) { fieldSchemaPb.setDescription(description); } + if (policyTags != null) { + fieldSchemaPb.setPolicyTags(policyTags.toPb()); + } if (getSubFields() != null) { List fieldsPb = Lists.transform(getSubFields(), TO_PB_FUNCTION); fieldSchemaPb.setFields(fieldsPb); @@ -332,6 +351,9 @@ static Field fromPb(TableFieldSchema fieldSchemaPb) { if (fieldSchemaPb.getDescription() != null) { fieldBuilder.setDescription(fieldSchemaPb.getDescription()); } + if (fieldSchemaPb.getPolicyTags() != null) { + fieldBuilder.setPolicyTags(PolicyTags.fromPb(fieldSchemaPb.getPolicyTags())); + } FieldList subFields = fieldSchemaPb.getFields() != null ? FieldList.of(Lists.transform(fieldSchemaPb.getFields(), FROM_PB_FUNCTION)) diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/PolicyTags.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/PolicyTags.java new file mode 100644 index 0000000000..a78fa92fbc --- /dev/null +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/PolicyTags.java @@ -0,0 +1,65 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.bigquery; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; +import java.io.Serializable; +import java.util.List; +import javax.annotation.Nullable; + +@AutoValue +public abstract class PolicyTags implements Serializable { + + private static final long serialVersionUID = 1L; + + @Nullable + abstract ImmutableList getNamesImmut(); + + public List getNames() { + return getNamesImmut(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + + abstract Builder setNamesImmut(ImmutableList namesImmut); + + public Builder setNames(List names) { + return setNamesImmut(ImmutableList.copyOf(names)); + } + + public abstract PolicyTags build(); + } + + public static Builder newBuilder() { + return new AutoValue_PolicyTags.Builder(); + } + + com.google.api.services.bigquery.model.TableFieldSchema.PolicyTags toPb() { + com.google.api.services.bigquery.model.TableFieldSchema.PolicyTags tagPb = + new com.google.api.services.bigquery.model.TableFieldSchema.PolicyTags(); + tagPb.setNames(getNames()); + return tagPb; + } + + static PolicyTags fromPb( + com.google.api.services.bigquery.model.TableFieldSchema.PolicyTags tagPb) { + return newBuilder().setNames(tagPb.getNames()).build(); + } +} diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java index 090bb8a27a..63c6752d73 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java @@ -25,6 +25,9 @@ public class SchemaTest { + private static PolicyTags POLICY_TAGS = + PolicyTags.newBuilder().setNames(ImmutableList.of("someTag")).build(); + private static final Field FIELD_SCHEMA1 = Field.newBuilder("StringField", LegacySQLTypeName.STRING) .setMode(Field.Mode.NULLABLE) @@ -34,12 +37,14 @@ public class SchemaTest { Field.newBuilder("IntegerField", LegacySQLTypeName.INTEGER) .setMode(Field.Mode.REPEATED) .setDescription("FieldDescription2") + .setPolicyTags(POLICY_TAGS) .build(); private static final Field FIELD_SCHEMA3 = Field.newBuilder("RecordField", LegacySQLTypeName.RECORD, FIELD_SCHEMA1, FIELD_SCHEMA2) .setMode(Field.Mode.REQUIRED) .setDescription("FieldDescription3") .build(); + private static final List FIELDS = ImmutableList.of(FIELD_SCHEMA1, FIELD_SCHEMA2, FIELD_SCHEMA3); private static final Schema TABLE_SCHEMA = Schema.of(FIELDS); diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java index 03b55dd4a4..472d8ecf8d 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java @@ -70,6 +70,7 @@ import com.google.cloud.bigquery.Model; import com.google.cloud.bigquery.ModelId; import com.google.cloud.bigquery.ModelInfo; +import com.google.cloud.bigquery.PolicyTags; import com.google.cloud.bigquery.QueryJobConfiguration; import com.google.cloud.bigquery.QueryParameterValue; import com.google.cloud.bigquery.RangePartitioning; @@ -141,6 +142,10 @@ public class ITBigQueryTest { ImmutableMap.of( "example-label1", "example-value1", "example-label2", "example-value2"); + private static final String sampleTag = + String.format("projects/%s/locations/us/taxonomies/1/policyTags/2", PROJECT_ID); + private static final PolicyTags POLICY_TAGS = + PolicyTags.newBuilder().setNames(ImmutableList.of(sampleTag)).build(); private static final Field TIMESTAMP_FIELD_SCHEMA = Field.newBuilder("TimestampField", LegacySQLTypeName.TIMESTAMP) .setMode(Field.Mode.NULLABLE) @@ -198,6 +203,12 @@ public class ITBigQueryTest { .setMode(Field.Mode.NULLABLE) .setDescription("NumericDescription") .build(); + private static final Field STRING_FIELD_SCHEMA_WITH_POLICY = + Field.newBuilder("StringFieldWithPolicy", LegacySQLTypeName.STRING) + .setMode(Field.Mode.NULLABLE) + .setDescription("field has a policy") + .setPolicyTags(POLICY_TAGS) + .build(); private static final Schema TABLE_SCHEMA = Schema.of( TIMESTAMP_FIELD_SCHEMA, @@ -211,6 +222,8 @@ public class ITBigQueryTest { GEOGRAPHY_FIELD_SCHEMA, NUMERIC_FIELD_SCHEMA); private static final Schema SIMPLE_SCHEMA = Schema.of(STRING_FIELD_SCHEMA); + private static final Schema POLICY_SCHEMA = + Schema.of(STRING_FIELD_SCHEMA, STRING_FIELD_SCHEMA_WITH_POLICY, INTEGER_FIELD_SCHEMA); private static final Schema QUERY_RESULT_SCHEMA = Schema.of( Field.newBuilder("TimestampField", LegacySQLTypeName.TIMESTAMP) @@ -514,6 +527,21 @@ public void testCreateTableWithRangePartitioning() { } } + public void testCreateTableWithPolicyTags() { + String tableName = "test_create_table_policytags"; + TableId tableId = TableId.of(DATASET, tableName); + try { + StandardTableDefinition tableDefinition = + StandardTableDefinition.newBuilder().setSchema(POLICY_SCHEMA).build(); + Table createdTable = bigquery.create(TableInfo.of(tableId, tableDefinition)); + assertNotNull(createdTable); + Table remoteTable = bigquery.getTable(DATASET, tableName); + assertEquals(POLICY_SCHEMA, remoteTable.getDefinition().getSchema()); + } finally { + bigquery.delete(tableId); + } + } + @Test public void testCreateAndGetTable() { String tableName = "test_create_and_get_table"; From b45ca43a6af62d1ff41fe2c899d5102c8393db35 Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Thu, 23 Apr 2020 15:42:08 -0400 Subject: [PATCH 04/12] 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 0000000000..47f096060a --- /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 3db81c9ae2..2db55ce3d0 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 ee3ddbd5fc..06e800ecf8 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 b1988a7f83..0000000000 --- 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 4a018664a5..c252ca41bf 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 37ed336799..69d7bf5659 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', From 21d0c588d61ded31cb45ff10bf7824f8203c9314 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 24 Apr 2020 17:41:51 +0200 Subject: [PATCH 05/12] deps: update dependency org.threeten:threetenbp to v1.4.4 (#293) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2c7758e037..fee76f539d 100644 --- a/pom.xml +++ b/pom.xml @@ -71,7 +71,7 @@ 3.11.4 4.13 29.0-android - 1.4.3 + 1.4.4 1.3.2 1.18 v2-rev20200324-1.30.9 From 2e0b894b7890a9e42210e734ab86ff91791c4dc6 Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Fri, 24 Apr 2020 11:46:07 -0400 Subject: [PATCH 06/12] samples: add samples README (#292) --- samples/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 samples/README.md diff --git a/samples/README.md b/samples/README.md new file mode 100644 index 0000000000..0b7ed99dda --- /dev/null +++ b/samples/README.md @@ -0,0 +1,17 @@ +# Getting Started with BigQuery Samples + +## Running a sample using Cloud Shell + +The Google Cloud Shell has application default credentials from its compute instance which will allow you to run an integration test without having to obtain `GOOGLE_APPLICATION_CREDENTIANS`. + +However, certain samples require environment variables to be set. For instance, in `CreateDatasetIT.java`: + +`private static final String GOOGLE_CLOUD_PROJECT = System.getenv("GOOGLE_CLOUD_PROJECT");` - this sample integration test requires you to specific the [Google Cloud Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects) you would like to run the test in. + +Make sure to set environment variables, if necessary, before running the sample, or else you will get an error asking you to set it. + +To run a samples integration tests in the cloud shell, simply run the following commands: + +`cd samples/snippets` - all samples are located in `java-bigquery/samples/snippets` directory. + +`mvn -Dtest=GetTableIT test` - this runs the integration test of `GetTable.java` sample. \ No newline at end of file From 217c9643b117a64f5981490159c9f7d30c12650a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 24 Apr 2020 17:48:10 +0200 Subject: [PATCH 07/12] chore(deps): update dependency com.google.cloud:libraries-bom to v5.2.0 (#291) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [com.google.cloud:libraries-bom](https://togithub.com/GoogleCloudPlatform/cloud-opensource-java) | minor | `5.1.0` -> `5.2.0` | --- ### Renovate configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#googleapis/java-bigquery). --- samples/snippets/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index b30107cc71..820ed6d92c 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -44,7 +44,7 @@ com.google.cloud libraries-bom - 5.1.0 + 5.2.0 pom import From b539f95965ddba6ce4fc5b6712ce1e38b8286bd7 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 24 Apr 2020 16:42:55 -0700 Subject: [PATCH 08/12] changes without context (#295) 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 | 2 +- synth.metadata | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 06e800ecf8..2eef47b11c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google com.google.cloud libraries-bom - 5.1.0 + 5.2.0 pom import diff --git a/synth.metadata b/synth.metadata index c252ca41bf..efa3fe3640 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,8 +3,8 @@ { "git": { "name": ".", - "remote": "git@github.com:stephaniewang526/java-bigquery.git", - "sha": "5992b8f263aefadb05a8e9f382374deea655f503" + "remote": "https://github.com/googleapis/java-bigquery.git", + "sha": "217c9643b117a64f5981490159c9f7d30c12650a" } }, { From 95f9443fad2f561df8f8108c3e323729d8195d46 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 28 Apr 2020 19:56:15 +0200 Subject: [PATCH 09/12] deps: update core transport dependencies to v1.35.0 (#298) --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index fee76f539d..8a0c96ab0a 100644 --- a/pom.xml +++ b/pom.xml @@ -91,12 +91,12 @@ com.google.http-client google-http-client-jackson2 - 1.34.2 + 1.35.0 com.google.http-client google-http-client - 1.34.2 + 1.35.0 com.google.auth From 9d37e45bc07de3d6b4fb2aac4c69df7b2ef80c9f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 29 Apr 2020 01:06:17 +0200 Subject: [PATCH 10/12] chore(deps): update dependency com.google.cloud:libraries-bom to v5.3.0 (#299) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [com.google.cloud:libraries-bom](https://togithub.com/GoogleCloudPlatform/cloud-opensource-java) | minor | `5.2.0` -> `5.3.0` | --- ### Renovate configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#googleapis/java-bigquery). --- samples/snippets/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 820ed6d92c..a022259b12 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -44,7 +44,7 @@ com.google.cloud libraries-bom - 5.2.0 + 5.3.0 pom import From d2a7af226735aba2c08867cd6606b19d1c31c2b0 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 29 Apr 2020 10:48:08 -0700 Subject: [PATCH 11/12] chore: regenerate README (#300) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/6f5d7f8b-8e06-474e-b3b8-e248dd7dd2e1/targets --- README.md | 2 +- synth.metadata | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2eef47b11c..d71201d05a 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google com.google.cloud libraries-bom - 5.2.0 + 5.3.0 pom import diff --git a/synth.metadata b/synth.metadata index efa3fe3640..3da64aa088 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-bigquery.git", - "sha": "217c9643b117a64f5981490159c9f7d30c12650a" + "sha": "9d37e45bc07de3d6b4fb2aac4c69df7b2ef80c9f" } }, { From 2b319ce21e2f540b7de4dfcef02c68a6cf8a1564 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2020 14:06:44 -0400 Subject: [PATCH 12/12] chore: release 1.111.2 (#294) * updated CHANGELOG.md [ci skip] * updated README.md [ci skip] * updated versions.txt [ci skip] * updated samples/pom.xml [ci skip] * updated google-cloud-bigquery/pom.xml [ci skip] * updated samples/snapshot/pom.xml [ci skip] * updated samples/install-without-bom/pom.xml [ci skip] * updated pom.xml [ci skip] * updated samples/snippets/pom.xml [ci skip] Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ README.md | 4 ++-- google-cloud-bigquery/pom.xml | 4 ++-- pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c59ec78ba5..5a34faf5af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +### [1.111.2](https://www.github.com/googleapis/java-bigquery/compare/v1.111.1...v1.111.2) (2020-04-29) + + +### Dependencies + +* update core transport dependencies to v1.35.0 ([#298](https://www.github.com/googleapis/java-bigquery/issues/298)) ([95f9443](https://www.github.com/googleapis/java-bigquery/commit/95f9443fad2f561df8f8108c3e323729d8195d46)) +* update dependency org.threeten:threetenbp to v1.4.4 ([#293](https://www.github.com/googleapis/java-bigquery/issues/293)) ([21d0c58](https://www.github.com/googleapis/java-bigquery/commit/21d0c588d61ded31cb45ff10bf7824f8203c9314)) + ### [1.111.1](https://www.github.com/googleapis/java-bigquery/compare/v1.111.0...v1.111.1) (2020-04-22) diff --git a/README.md b/README.md index d71201d05a..1b7b5f81b6 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,11 @@ If you are using Maven without BOM, add this to your dependencies: If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.cloud:google-cloud-bigquery:1.111.1' +compile 'com.google.cloud:google-cloud-bigquery:1.111.2' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "1.111.1" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "1.111.2" ``` [//]: # ({x-version-update-end}) diff --git a/google-cloud-bigquery/pom.xml b/google-cloud-bigquery/pom.xml index 89a0af6893..1b7aefc602 100644 --- a/google-cloud-bigquery/pom.xml +++ b/google-cloud-bigquery/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-bigquery - 1.111.2-SNAPSHOT + 1.111.2 jar BigQuery https://github.com/googleapis/java-bigquery @@ -11,7 +11,7 @@ com.google.cloud google-cloud-bigquery-parent - 1.111.2-SNAPSHOT + 1.111.2 google-cloud-bigquery diff --git a/pom.xml b/pom.xml index 8a0c96ab0a..72dbf5e7c0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-bigquery-parent pom - 1.111.2-SNAPSHOT + 1.111.2 BigQuery Parent https://github.com/googleapis/java-bigquery @@ -116,7 +116,7 @@ com.google.cloud google-cloud-bigquery - 1.111.2-SNAPSHOT + 1.111.2 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 0fd14b538f..f2a1f96a9b 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -44,7 +44,7 @@ com.google.cloud google-cloud-bigquery - 1.111.2-SNAPSHOT + 1.111.2 diff --git a/versions.txt b/versions.txt index 90e08c2797..323882b01d 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-bigquery:1.111.1:1.111.2-SNAPSHOT \ No newline at end of file +google-cloud-bigquery:1.111.2:1.111.2 \ No newline at end of file