diff --git a/bigquery/cloud-client/src/main/java/com/example/bigquery/AuthSnippets.java b/bigquery/cloud-client/src/main/java/com/example/bigquery/AuthSnippets.java index 67065e56de7..09fc6d83ac6 100644 --- a/bigquery/cloud-client/src/main/java/com/example/bigquery/AuthSnippets.java +++ b/bigquery/cloud-client/src/main/java/com/example/bigquery/AuthSnippets.java @@ -32,7 +32,7 @@ */ public class AuthSnippets { - // [START default_credentials] + // [START bigquery_client_default_credentials] public static void implicit() { // Instantiate a client. If you don't specify credentials when constructing a client, the // client library will look for credentials in the environment, such as the @@ -45,9 +45,9 @@ public static void implicit() { System.out.printf("%s%n", dataset.getDatasetId().getDataset()); } } - // [END default_credentials] + // [END bigquery_client_default_credentials] - // [START explicit_service_account] + // [START bigquery_client_json_credentials] public static void explicit() throws IOException { // Load credentials from JSON key file. If you can't set the GOOGLE_APPLICATION_CREDENTIALS // environment variable, you can explicitly load the credentials file to construct the @@ -68,7 +68,7 @@ public static void explicit() throws IOException { System.out.printf("%s%n", dataset.getDatasetId().getDataset()); } } - // [END explicit_service_account] + // [END bigquery_client_json_credentials] public static void main(String... args) throws IOException { boolean validArgs = args.length == 1; diff --git a/bigquery/cloud-client/src/main/java/com/example/bigquery/QueryParametersSample.java b/bigquery/cloud-client/src/main/java/com/example/bigquery/QueryParametersSample.java deleted file mode 100644 index 9690b51ade4..00000000000 --- a/bigquery/cloud-client/src/main/java/com/example/bigquery/QueryParametersSample.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * 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.example.bigquery; - -import com.google.cloud.bigquery.BigQuery; -import com.google.cloud.bigquery.BigQueryOptions; -import com.google.cloud.bigquery.FieldValue; -import com.google.cloud.bigquery.QueryJobConfiguration; -import com.google.cloud.bigquery.QueryParameterValue; -import com.google.cloud.bigquery.TableResult; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormatter; -import org.joda.time.format.ISODateTimeFormat; - -/** A sample that demonstrates use of query parameters. */ -public class QueryParametersSample { - private static final int ERROR_CODE = 1; - - private static void printUsage() { - System.err.println("Usage:"); - System.err.printf( - "\tmvn exec:java -Dexec.mainClass=%s -Dexec.args='%s'\n", - QueryParametersSample.class.getCanonicalName(), "${sample}"); - System.err.println(); - System.err.println("${sample} can be one of: named, array, timestamp"); - System.err.println(); - System.err.println("Usage for ${sample}=named:"); - System.err.printf( - "\tmvn exec:java -Dexec.mainClass=%s -Dexec.args='%s'\n", - QueryParametersSample.class.getCanonicalName(), "named ${corpus} ${minWordCount}"); - System.err.println(); - System.err.println("Usage for sample=array:"); - System.err.printf( - "\tmvn exec:java -Dexec.mainClass=%s -Dexec.args='%s'\n", - QueryParametersSample.class.getCanonicalName(), "array ${gender} ${states...}"); - System.err.println(); - System.err.println("\twhere ${gender} can be on of: M, F"); - System.err.println( - "\tand ${states} is any upper-case 2-letter code for U.S. a state, e.g. CA."); - System.err.println(); - System.err.printf( - "\t\tmvn exec:java -Dexec.mainClass=%s -Dexec.args='%s'\n", - QueryParametersSample.class.getCanonicalName(), "array F MD WA"); - } - - /** Prompts the user for the required parameters to perform a query. */ - public static void main(final String[] args) throws IOException, InterruptedException { - if (args.length < 1) { - System.err.println("Expected first argument 'sample'"); - printUsage(); - System.exit(ERROR_CODE); - } - String sample = args[0]; - - switch (sample) { - case "named": - if (args.length != 3) { - System.err.println("Unexpected number of arguments for named query sample."); - printUsage(); - System.exit(ERROR_CODE); - } - runNamed(args[1], Long.parseLong(args[2])); - break; - case "array": - if (args.length < 2) { - System.err.println("Unexpected number of arguments for array query sample."); - printUsage(); - System.exit(ERROR_CODE); - } - String gender = args[1]; - String[] states = Arrays.copyOfRange(args, 2, args.length); - runArray(gender, states); - break; - case "timestamp": - if (args.length != 1) { - System.err.println("Unexpected number of arguments for timestamp query sample."); - printUsage(); - System.exit(ERROR_CODE); - } - runTimestamp(); - break; - default: - System.err.println("Got bad value for sample"); - printUsage(); - System.exit(ERROR_CODE); - } - } - - /** - * Query the Shakespeare dataset for words with count at least {@code minWordCount} in the corpus - * {@code corpus}. - */ - // [START bigquery_query_params] - private static void runNamed(final String corpus, final long minWordCount) - throws InterruptedException { - BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); - - String queryString = - "SELECT word, word_count\n" - + "FROM `bigquery-public-data.samples.shakespeare`\n" - + "WHERE corpus = @corpus\n" - + "AND word_count >= @min_word_count\n" - + "ORDER BY word_count DESC"; - QueryJobConfiguration queryRequest = - QueryJobConfiguration.newBuilder(queryString) - .addNamedParameter("corpus", QueryParameterValue.string(corpus)) - .addNamedParameter("min_word_count", QueryParameterValue.int64(minWordCount)) - // Standard SQL syntax is required for parameterized queries. - // See: https://cloud.google.com/bigquery/sql-reference/ - .setUseLegacySql(false) - .build(); - - // Execute the query. - TableResult result = bigquery.query(queryRequest); - - // Print all pages of the results. - while (result != null) { - for (List row : result.iterateAll()) { - System.out.printf("%s: %d\n", row.get(0).getStringValue(), row.get(1).getLongValue()); - } - - result = result.getNextPage(); - } - } - // [END bigquery_query_params] - - /** - * Query the baby names database to find the most popular names for a gender in a list of states. - */ - // [START bigquery_query_params_arrays] - private static void runArray(String gender, String[] states) throws InterruptedException { - BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); - - String queryString = - "SELECT name, sum(number) as count\n" - + "FROM `bigquery-public-data.usa_names.usa_1910_2013`\n" - + "WHERE gender = @gender\n" - + "AND state IN UNNEST(@states)\n" - + "GROUP BY name\n" - + "ORDER BY count DESC\n" - + "LIMIT 10;"; - QueryJobConfiguration queryRequest = - QueryJobConfiguration.newBuilder(queryString) - .addNamedParameter("gender", QueryParameterValue.string(gender)) - .addNamedParameter("states", QueryParameterValue.array(states, String.class)) - // Standard SQL syntax is required for parameterized queries. - // See: https://cloud.google.com/bigquery/sql-reference/ - .setUseLegacySql(false) - .build(); - - // Execute the query. - TableResult result = bigquery.query(queryRequest); - - // Print all pages of the results. - while (result != null) { - for (List row : result.iterateAll()) { - System.out.printf("%s: %d\n", row.get(0).getStringValue(), row.get(1).getLongValue()); - } - - result = result.getNextPage(); - } - } - // [END bigquery_query_params_arrays] - - // [START bigquery_query_params_timestamps] - private static void runTimestamp() throws InterruptedException { - BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); - - DateTime timestamp = new DateTime(2016, 12, 7, 8, 0, 0, DateTimeZone.UTC); - - String queryString = "SELECT TIMESTAMP_ADD(@ts_value, INTERVAL 1 HOUR);"; - QueryJobConfiguration queryRequest = - QueryJobConfiguration.newBuilder(queryString) - .addNamedParameter( - "ts_value", - QueryParameterValue.timestamp( - // Timestamp takes microseconds since 1970-01-01T00:00:00 UTC - timestamp.getMillis() * 1000)) - // Standard SQL syntax is required for parameterized queries. - // See: https://cloud.google.com/bigquery/sql-reference/ - .setUseLegacySql(false) - .build(); - - // Execute the query. - TableResult result = bigquery.query(queryRequest); - - // Print all pages of the results. - DateTimeFormatter formatter = ISODateTimeFormat.dateTimeNoMillis().withZoneUTC(); - while (result != null) { - for (List row : result.iterateAll()) { - System.out.printf( - "%s\n", - formatter.print( - new DateTime( - // Timestamp values are returned in microseconds since 1970-01-01T00:00:00 UTC, - // but org.joda.time.DateTime constructor accepts times in milliseconds. - row.get(0).getTimestampValue() / 1000, DateTimeZone.UTC))); - } - - result = result.getNextPage(); - } - } - // [END bigquery_query_params_timestamps] -} diff --git a/bigquery/cloud-client/src/main/java/com/example/bigquery/QuerySample.java b/bigquery/cloud-client/src/main/java/com/example/bigquery/QuerySample.java deleted file mode 100644 index 26e182fc8b4..00000000000 --- a/bigquery/cloud-client/src/main/java/com/example/bigquery/QuerySample.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * 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.example.bigquery; - -import com.google.cloud.bigquery.BigQuery; -import com.google.cloud.bigquery.BigQueryOptions; -import com.google.cloud.bigquery.FieldValue; -import com.google.cloud.bigquery.Job; -import com.google.cloud.bigquery.JobId; -import com.google.cloud.bigquery.JobInfo; -import com.google.cloud.bigquery.QueryJobConfiguration; -import com.google.cloud.bigquery.TableId; -import com.google.cloud.bigquery.TableResult; -import java.io.IOException; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.TimeoutException; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.DefaultParser; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.OptionGroup; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; - -/** Runs a query against BigQuery. */ -public class QuerySample { - // [START query_config_simple] - public static void runSimpleQuery(String queryString) - throws TimeoutException, InterruptedException { - QueryJobConfiguration queryConfig = - QueryJobConfiguration.newBuilder(queryString).build(); - - runQuery(queryConfig); - } - // [END query_config_simple] - - // [START query_config_standard_sql] - public static void runStandardSqlQuery(String queryString) - throws TimeoutException, InterruptedException { - QueryJobConfiguration queryConfig = - QueryJobConfiguration.newBuilder(queryString) - // To use standard SQL syntax, set useLegacySql to false. See: - // https://cloud.google.com/bigquery/docs/reference/standard-sql/enabling-standard-sql - .setUseLegacySql(false) - .build(); - - runQuery(queryConfig); - } - // [END query_config_standard_sql] - - // [START query_config_permanent_table] - public static void runQueryPermanentTable( - String queryString, - String destinationDataset, - String destinationTable, - boolean allowLargeResults) throws TimeoutException, InterruptedException { - QueryJobConfiguration queryConfig = - QueryJobConfiguration.newBuilder(queryString) - // Save the results of the query to a permanent table. See: - // https://cloud.google.com/bigquery/docs/writing-results#permanent-table - .setDestinationTable(TableId.of(destinationDataset, destinationTable)) - // Allow results larger than the maximum response size. - // If true, a destination table must be set. See: - // https://cloud.google.com/bigquery/docs/writing-results#large-results - .setAllowLargeResults(allowLargeResults) - .build(); - - runQuery(queryConfig); - } - // [END query_config_permanent_table] - - // [START query_config_cache] - public static void runUncachedQuery(String queryString) - throws TimeoutException, InterruptedException { - QueryJobConfiguration queryConfig = - QueryJobConfiguration.newBuilder(queryString) - // Do not use the query cache. Force live query evaluation. See: - // https://cloud.google.com/bigquery/docs/cached-results#disabling_retrieval_of_cached_results - .setUseQueryCache(false) - .build(); - - runQuery(queryConfig); - } - // [END query_config_cache] - - // [START query_config_batch] - public static void runBatchQuery(String queryString) - throws TimeoutException, InterruptedException { - QueryJobConfiguration queryConfig = - QueryJobConfiguration.newBuilder(queryString) - // Run at batch priority, which won't count toward concurrent rate - // limit. See: - // https://cloud.google.com/bigquery/docs/running-queries#batch - .setPriority(QueryJobConfiguration.Priority.BATCH) - .build(); - - runQuery(queryConfig); - } - // [END query_config_batch] - - - // [START run_query] - public static void runQuery(QueryJobConfiguration queryConfig) - throws TimeoutException, InterruptedException { - BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); - - // Create a job ID so that we can safely retry. - JobId jobId = JobId.of(UUID.randomUUID().toString()); - Job queryJob = bigquery.create(JobInfo.newBuilder(queryConfig).setJobId(jobId).build()); - - // Wait for the query to complete. - queryJob = queryJob.waitFor(); - - // Check for errors - if (queryJob == null) { - throw new RuntimeException("Job no longer exists"); - } else if (queryJob.getStatus().getError() != null) { - // You can also look at queryJob.getStatus().getExecutionErrors() for all - // errors, not just the latest one. - throw new RuntimeException(queryJob.getStatus().getError().toString()); - } - - // Get the results. - TableResult result = queryJob.getQueryResults(); - - // Print all pages of the results. - while (result != null) { - for (List row : result.iterateAll()) { - for (FieldValue val : row) { - System.out.printf("%s,", val.toString()); - } - System.out.printf("\n"); - } - - result = result.getNextPage(); - } - } - // [END run_query] - - /** Prompts the user for the required parameters to perform a query. */ - public static void main(final String[] args) - throws IOException, InterruptedException, TimeoutException, ParseException { - //CHECKSTYLE OFF: VariableDeclarationUsageDistance - improves readability - Options options = new Options(); - //CHECKSTLYE ON: VariableDeclarationUsageDistance - // Use an OptionsGroup to choose which sample to run. - OptionGroup samples = new OptionGroup(); - samples.addOption(Option.builder().longOpt("runSimpleQuery").build()); - samples.addOption(Option.builder().longOpt("runStandardSqlQuery").build()); - samples.addOption(Option.builder().longOpt("runPermanentTableQuery").build()); - samples.addOption(Option.builder().longOpt("runUncachedQuery").build()); - samples.addOption(Option.builder().longOpt("runBatchQuery").build()); - samples.isRequired(); - options.addOptionGroup(samples); - - options.addOption(Option.builder().longOpt("query").hasArg().required().build()); - options.addOption(Option.builder().longOpt("destDataset").hasArg().build()); - options.addOption(Option.builder().longOpt("destTable").hasArg().build()); - options.addOption(Option.builder().longOpt("allowLargeResults").build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine cmd = parser.parse(options, args); - - String query = cmd.getOptionValue("query"); - if (cmd.hasOption("runSimpleQuery")) { - runSimpleQuery(query); - } else if (cmd.hasOption("runStandardSqlQuery")) { - runStandardSqlQuery(query); - } else if (cmd.hasOption("runPermanentTableQuery")) { - String destDataset = cmd.getOptionValue("destDataset"); - String destTable = cmd.getOptionValue("destTable"); - boolean allowLargeResults = cmd.hasOption("allowLargeResults"); - runQueryPermanentTable(query, destDataset, destTable, allowLargeResults); - } else if (cmd.hasOption("runUncachedQuery")) { - runUncachedQuery(query); - } else if (cmd.hasOption("runBatchQuery")) { - runBatchQuery(query); - } - } -} diff --git a/bigquery/cloud-client/src/test/java/com/example/bigquery/QueryParametersSampleIT.java b/bigquery/cloud-client/src/test/java/com/example/bigquery/QueryParametersSampleIT.java deleted file mode 100644 index b79b53aeef8..00000000000 --- a/bigquery/cloud-client/src/test/java/com/example/bigquery/QueryParametersSampleIT.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * 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.example.bigquery; - -import static com.google.common.truth.Truth.assertThat; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Tests for simple app sample. */ -@RunWith(JUnit4.class) -@SuppressWarnings("checkstyle:abbreviationaswordinname") -public class QueryParametersSampleIT { - private ByteArrayOutputStream bout; - private PrintStream out; - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - } - - @After - public void tearDown() { - System.setOut(null); - } - - @Test - public void testNamedSample() throws Exception { - QueryParametersSample.main(new String[] {"named", "romeoandjuliet", "100"}); - String got = bout.toString(); - assertThat(got).contains("love"); - } - - @Test - public void testArraySample() throws Exception { - QueryParametersSample.main(new String[] {"array", "M", "WA", "WI", "WV", "WY"}); - String got = bout.toString(); - assertThat(got).contains("James"); - } - - @Test - public void testTimestampSample() throws Exception { - QueryParametersSample.main(new String[] {"timestamp"}); - String got = bout.toString(); - assertThat(got).contains("2016-12-07T09:00:00Z"); - } -} diff --git a/bigquery/cloud-client/src/test/java/com/example/bigquery/QuerySampleIT.java b/bigquery/cloud-client/src/test/java/com/example/bigquery/QuerySampleIT.java deleted file mode 100644 index 8f7a2b9baed..00000000000 --- a/bigquery/cloud-client/src/test/java/com/example/bigquery/QuerySampleIT.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * 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.example.bigquery; - -import static com.google.common.truth.Truth.assertThat; - -import com.google.cloud.bigquery.BigQuery; -import com.google.cloud.bigquery.BigQueryOptions; -import com.google.cloud.bigquery.DatasetId; -import com.google.cloud.bigquery.DatasetInfo; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Tests for query sample. */ -@RunWith(JUnit4.class) -@SuppressWarnings("checkstyle:abbreviationaswordinname") -public class QuerySampleIT { - private static final String LEGACY_SQL_QUERY = - "SELECT corpus FROM [bigquery-public-data:samples.shakespeare] GROUP BY corpus;"; - private static final String STANDARD_SQL_QUERY = - "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; - private static final String CORPUS_NAME = "romeoandjuliet"; - private static final String TEST_DATASET = "query_sample_test"; - private static final String TEST_TABLE = "query_sample_test"; - private ByteArrayOutputStream bout; - private PrintStream out; - - private static final void deleteTestDataset() { - BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); - DatasetId datasetId = DatasetId.of(TEST_DATASET); - BigQuery.DatasetDeleteOption deleteContents = BigQuery.DatasetDeleteOption.deleteContents(); - bigquery.delete(datasetId, deleteContents); - } - - private static final void createTestDataset() { - BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); - DatasetId datasetId = DatasetId.of(TEST_DATASET); - bigquery.create(DatasetInfo.newBuilder(datasetId).build()); - } - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - } - - @After - public void tearDown() { - System.setOut(null); - } - - @Test - public void testSimpleQuery() throws Exception { - QuerySample.main(new String[]{"--query", STANDARD_SQL_QUERY, "--runSimpleQuery"}); - String got = bout.toString(); - assertThat(got).contains(CORPUS_NAME); - } - - @Test - public void testStandardSqlQuery() throws Exception { - QuerySample.main(new String[]{"--query", STANDARD_SQL_QUERY, "--runStandardSqlQuery"}); - String got = bout.toString(); - assertThat(got).contains(CORPUS_NAME); - } - - @Test - public void testUncachedQuery() throws Exception { - QuerySample.main(new String[]{"--query", STANDARD_SQL_QUERY, "--runSimpleQuery"}); - String got = bout.toString(); - assertThat(got).contains(CORPUS_NAME); - } - - @Test - // Exclude this test from system tests. Batch queries usually start within a - // few minutes, but may not get scheduled for up to 24 hours. - // See: https://cloud.google.com/bigquery/querying-data#interactive-batch - @Ignore - public void testBatchQuery() throws Exception { - QuerySample.main(new String[]{"--query", STANDARD_SQL_QUERY, "--runBatchQuery"}); - String got = bout.toString(); - assertThat(got).contains(CORPUS_NAME); - } - - @Test - public void testPermanentTableQuery() throws Exception { - // Setup the test data. - deleteTestDataset(); - createTestDataset(); - - QuerySample.main( - new String[]{ - "--query", - STANDARD_SQL_QUERY, - "--runPermanentTableQuery", - "--destDataset", - TEST_DATASET, - "--destTable", - TEST_TABLE, - "--allowLargeResults"}); - String got = bout.toString(); - assertThat(got).contains(CORPUS_NAME); - - // Cleanup the test data. - deleteTestDataset(); - } -} diff --git a/bigquery/rest/src/main/java/com/example/bigquery/LabelsSample.java b/bigquery/rest/src/main/java/com/example/bigquery/LabelsSample.java index 256dec44d56..4545bfc3db4 100644 --- a/bigquery/rest/src/main/java/com/example/bigquery/LabelsSample.java +++ b/bigquery/rest/src/main/java/com/example/bigquery/LabelsSample.java @@ -37,7 +37,7 @@ /** Sample demonstrating labeling a BigQuery dataset or table. */ public class LabelsSample { - // [START label_dataset] + // [START bigquery_label_dataset] static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport(); static final JsonFactory JSON_FACTORY = new JacksonFactory(); @@ -105,9 +105,9 @@ public static void labelDataset( "Updated label \"%s\" with value \"%s\"\n", labelKey, responseDataset.getLabels().get(labelKey)); } - // [END label_dataset] + // [END bigquery_label_dataset] - // [START label_table] + // [START bigquery_label_table] public static class Table { @Key private Map labels; @@ -178,7 +178,7 @@ public static void labelTable( "Updated label \"%s\" with value \"%s\"\n", labelKey, responseTable.getLabels().get(labelKey)); } - // [END label_table] + // [END bigquery_label_table] public static void printUsage() { System.err.println("Command expects 4 or 5 arguments:");