diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java index e391c054d..675e6c1e8 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java @@ -699,20 +699,17 @@ public int hashCode() { * *
Example of creating a dataset. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * Dataset dataset = null; - * DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetName).build(); - * try { - * // the dataset was created - * dataset = bigquery.create(datasetInfo); - * } catch (BigQueryException e) { - * // the dataset was not created - * } + ** * @throws BigQueryException upon failure */ @@ -723,22 +720,19 @@ public int hashCode() { * *{@code + * String datasetName = "my_dataset_name"; + * Dataset dataset = null; + * DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetName).build(); + * try { + * // the dataset was created + * dataset = bigquery.create(datasetInfo); + * } catch (BigQueryException e) { + * // the dataset was not created * } - *+ * }
Example of creating a table. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * String tableName = "my_table_name"; - * String fieldName = "string_field"; - * TableId tableId = TableId.of(datasetName, tableName); - * // Table field definition - * Field field = Field.of(fieldName, LegacySQLTypeName.STRING); - * // Table schema definition - * Schema schema = Schema.of(field); - * TableDefinition tableDefinition = StandardTableDefinition.of(schema); - * TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build(); - * Table table = bigquery.create(tableInfo); - * } - *+ *
{@code + * String datasetName = "my_dataset_name"; + * String tableName = "my_table_name"; + * String fieldName = "string_field"; + * TableId tableId = TableId.of(datasetName, tableName); + * // Table field definition + * Field field = Field.of(fieldName, LegacySQLTypeName.STRING); + * // Table schema definition + * Schema schema = Schema.of(field); + * TableDefinition tableDefinition = StandardTableDefinition.of(schema); + * TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build(); + * Table table = bigquery.create(tableInfo); + * }* * @throws BigQueryException upon failure */ @@ -756,46 +750,41 @@ public int hashCode() { * *
Example of loading a newline-delimited-json file with textual fields from GCS to a table. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * String tableName = "my_table_name"; - * String sourceUri = "gs://cloud-samples-data/bigquery/us-states/us-states.json"; - * TableId tableId = TableId.of(datasetName, tableName); - * // Table field definition - * Field[] fields = new Field[] { Field.of("name", LegacySQLTypeName.STRING), - * Field.of("post_abbr", LegacySQLTypeName.STRING) }; - * // Table schema definition - * Schema schema = Schema.of(fields); - * LoadJobConfiguration configuration = LoadJobConfiguration.builder(tableId, sourceUri) - * .setFormatOptions(FormatOptions.json()).setCreateDisposition(CreateDisposition.CREATE_IF_NEEDED) - * .setSchema(schema).build(); - * // Load the table - * Job loadJob = bigquery.create(JobInfo.of(configuration)); - * loadJob = loadJob.waitFor(); - * // Check the table - * System.out.println("State: " + loadJob.getStatus().getState()); - * return ((StandardTableDefinition) bigquery.getTable(tableId).getDefinition()).getNumRows(); - * } - *+ *
{@code + * String datasetName = "my_dataset_name"; + * String tableName = "my_table_name"; + * String sourceUri = "gs://cloud-samples-data/bigquery/us-states/us-states.json"; + * TableId tableId = TableId.of(datasetName, tableName); + * // Table field definition + * Field[] fields = new Field[] { Field.of("name", LegacySQLTypeName.STRING), + * Field.of("post_abbr", LegacySQLTypeName.STRING) }; + * // Table schema definition + * Schema schema = Schema.of(fields); + * LoadJobConfiguration configuration = LoadJobConfiguration.builder(tableId, sourceUri) + * .setFormatOptions(FormatOptions.json()) + * .setCreateDisposition(CreateDisposition.CREATE_IF_NEEDED) + * .setSchema(schema).build(); + * // Load the table + * Job loadJob = bigquery.create(JobInfo.of(configuration)); + * loadJob = loadJob.waitFor(); + * // Check the table + * System.out.println("State: " + loadJob.getStatus().getState()); + * return ((StandardTableDefinition) bigquery.getTable(tableId).getDefinition()).getNumRows(); + * }* *
Example of creating a query job. * - *
- * { - * @code - * String query = "SELECT field FROM my_dataset_name.my_table_name"; - * Job job = null; - * JobConfiguration jobConfiguration = QueryJobConfiguration.of(query); - * JobInfo jobInfo = JobInfo.of(jobConfiguration); - * try { - * job = bigquery.create(jobInfo); - * } catch (BigQueryException e) { - * // the job was not created - * } + ** * @throws BigQueryException upon failure */ @@ -808,18 +797,15 @@ public int hashCode() { * *{@code + * String query = "SELECT field FROM my_dataset_name.my_table_name"; + * Job job = null; + * JobConfiguration jobConfiguration = QueryJobConfiguration.of(query); + * JobInfo jobInfo = JobInfo.of(jobConfiguration); + * try { + * job = bigquery.create(jobInfo); + * } catch (BigQueryException e) { + * // the job was not created * } - *+ * }
Example of creating a query connection. * - *
- * { - * @code - * ConnectionSettings connectionSettings = - * ConnectionSettings.newBuilder() - * .setRequestTimeout(10L) - * .setMaxResults(100L) - * .setUseQueryCache(true) - * .build(); - * Connection connection = bigquery.createConnection(connectionSettings); - * } - *+ *
{@code + * ConnectionSettings connectionSettings = + * ConnectionSettings.newBuilder() + * .setRequestTimeout(10L) + * .setMaxResults(100L) + * .setUseQueryCache(true) + * .build(); + * Connection connection = bigquery.createConnection(connectionSettings); + * }* * @throws BigQueryException upon failure * @param connectionSettings @@ -836,12 +822,9 @@ public int hashCode() { * *
Example of creating a query connection. * - *
- * { - * @code - * Connection connection = bigquery.createConnection(); - * } - *+ *
{@code + * Connection connection = bigquery.createConnection(); + * }* * @throws BigQueryException upon failure */ @@ -853,13 +836,10 @@ public int hashCode() { * *
Example of getting a dataset. * - *
- * { - * @code - * String datasetName = "my_dataset"; - * Dataset dataset = bigquery.getDataset(datasetName); - * } - *+ *
{@code + * String datasetName = "my_dataset"; + * Dataset dataset = bigquery.getDataset(datasetName); + * }* * @throws BigQueryException upon failure */ @@ -870,15 +850,12 @@ public int hashCode() { * *
Example of getting a dataset. * - *
- * { - * @code - * String projectId = "my_project_id"; - * String datasetName = "my_dataset_name"; - * DatasetId datasetId = DatasetId.of(projectId, datasetName); - * Dataset dataset = bigquery.getDataset(datasetId); - * } - *+ *
{@code + * String projectId = "my_project_id"; + * String datasetName = "my_dataset_name"; + * DatasetId datasetId = DatasetId.of(projectId, datasetName); + * Dataset dataset = bigquery.getDataset(datasetId); + * }* * @throws BigQueryException upon failure */ @@ -892,16 +869,13 @@ public int hashCode() { * *
Example of listing datasets, specifying the page size. * - *
- * { - * @code - * // List datasets in the default project - * Page<Dataset> datasets = bigquery.listDatasets(DatasetListOption.pageSize(100)); - * for (Dataset dataset : datasets.iterateAll()) { - * // do something with the dataset - * } + ** * @throws BigQueryException upon failure */ @@ -915,17 +889,14 @@ public int hashCode() { * *{@code + * // List datasets in the default project + * Page+ * }datasets = bigquery.listDatasets(DatasetListOption.pageSize(100)); + * for (Dataset dataset : datasets.iterateAll()) { + * // do something with the dataset * } - *
Example of listing datasets in a project, specifying the page size. * - *
- * { - * @code - * String projectId = "my_project_id"; - * // List datasets in a specified project - * Page<{@link Dataset}> datasets = bigquery.listDatasets(projectId, DatasetListOption.pageSize(100)); - * for (Dataset dataset : datasets.iterateAll()) { - * // do something with the dataset - * } + ** * @throws BigQueryException upon failure */ @@ -936,18 +907,15 @@ public int hashCode() { * *{@code + * String projectId = "my_project_id"; + * // List datasets in a specified project + * Page+ * }datasets = bigquery.listDatasets(projectId, DatasetListOption.pageSize(100)); + * for (Dataset dataset : datasets.iterateAll()) { + * // do something with the dataset * } - *
Example of deleting a dataset from its id, even if non-empty. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * boolean deleted = bigquery.delete(datasetName, DatasetDeleteOption.deleteContents()); - * if (deleted) { - * // the dataset was deleted - * } else { - * // the dataset was not found - * } + ** * @return {@code true} if dataset was deleted, {@code false} if it was not found * @throws BigQueryException upon failure @@ -959,20 +927,17 @@ public int hashCode() { * *{@code + * String datasetName = "my_dataset_name"; + * boolean deleted = bigquery.delete(datasetName, DatasetDeleteOption.deleteContents()); + * if (deleted) { + * // the dataset was deleted + * } else { + * // the dataset was not found * } - *+ * }
Example of deleting a dataset, even if non-empty. * - *
- * { - * @code - * String projectId = "my_project_id"; - * String datasetName = "my_dataset_name"; - * DatasetId datasetId = DatasetId.of(projectId, datasetName); - * boolean deleted = bigquery.delete(datasetId, DatasetDeleteOption.deleteContents()); - * if (deleted) { - * // the dataset was deleted - * } else { - * // the dataset was not found - * } + ** * @return {@code true} if dataset was deleted, {@code false} if it was not found * @throws BigQueryException upon failure @@ -996,21 +961,18 @@ public int hashCode() { * *{@code + * String projectId = "my_project_id"; + * String datasetName = "my_dataset_name"; + * DatasetId datasetId = DatasetId.of(projectId, datasetName); + * boolean deleted = bigquery.delete(datasetId, DatasetDeleteOption.deleteContents()); + * if (deleted) { + * // the dataset was deleted + * } else { + * // the dataset was not found * } - *+ * }
Example of deleting a table. * - *
- * { - * @code - * String projectId = "my_project_id"; - * String datasetName = "my_dataset_name"; - * String tableName = "my_table_name"; - * TableId tableId = TableId.of(projectId, datasetName, tableName); - * boolean deleted = bigquery.delete(tableId); - * if (deleted) { - * // the table was deleted - * } else { - * // the table was not found - * } + ** * @return {@code true} if table was deleted, {@code false} if it was not found * @throws BigQueryException upon failure @@ -1022,21 +984,18 @@ public int hashCode() { * *{@code + * String projectId = "my_project_id"; + * String datasetName = "my_dataset_name"; + * String tableName = "my_table_name"; + * TableId tableId = TableId.of(projectId, datasetName, tableName); + * boolean deleted = bigquery.delete(tableId); + * if (deleted) { + * // the table was deleted + * } else { + * // the table was not found * } - *+ * }
Example of deleting a model. * - *
- * { - * @code - * String projectId = "my_project_id"; - * String datasetName = "my_dataset_name"; - * String tableName = "my_model_name"; - * ModelId modelId = ModelId.of(projectId, datasetName, modelName); - * boolean deleted = bigquery.delete(modelId); - * if (deleted) { - * // the model was deleted - * } else { - * // the model was not found - * } + ** * @return {@code true} if model was deleted, {@code false} if it was not found * @throws BigQueryException upon failure @@ -1081,19 +1040,15 @@ public int hashCode() { * * - *{@code + * String projectId = "my_project_id"; + * String datasetName = "my_dataset_name"; + * String tableName = "my_model_name"; + * ModelId modelId = ModelId.of(projectId, datasetName, modelName); + * boolean deleted = bigquery.delete(modelId); + * if (deleted) { + * // the model was deleted + * } else { + * // the model was not found * } - *+ * }
- * { - * @code - * // String datasetName = "my_dataset_name"; - * // String tableName = "my_table_name"; - * // String newDescription = "new_description"; - * - * Table beforeTable = bigquery.getTable(datasetName, tableName); - * TableInfo tableInfo = beforeTable.toBuilder().setDescription(newDescription).build(); - * Table afterTable = bigquery.update(tableInfo); + ** * * @@ -1106,33 +1061,27 @@ public int hashCode() { * *{@code + * // String datasetName = "my_dataset_name"; + * // String tableName = "my_table_name"; + * // String newDescription = "new_description"; * - * } - *+ * Table beforeTable = bigquery.getTable(datasetName, tableName); + * TableInfo tableInfo = beforeTable.toBuilder().setDescription(newDescription).build(); + * Table afterTable = bigquery.update(tableInfo); + * }
Example of updating a table by changing its description. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * String tableName = "my_table_name"; - * String newDescription = "new_description"; - * Table beforeTable = bigquery.getTable(datasetName, tableName); - * TableInfo tableInfo = beforeTable.toBuilder().setDescription(newDescription).build(); - * Table afterTable = bigquery.update(tableInfo); - * } - *+ *
{@code + * String datasetName = "my_dataset_name"; + * String tableName = "my_table_name"; + * String newDescription = "new_description"; + * Table beforeTable = bigquery.getTable(datasetName, tableName); + * TableInfo tableInfo = beforeTable.toBuilder().setDescription(newDescription).build(); + * Table afterTable = bigquery.update(tableInfo); + * }* *
Example of updating a table by changing its expiration. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * String tableName = "my_table_name"; - * Table beforeTable = bigquery.getTable(datasetName, tableName); - * - * // Set table to expire 5 days from now. - * long expirationMillis = DateTime.now().plusDays(5).getMillis(); - * TableInfo tableInfo = beforeTable.toBuilder().setExpirationTime(expirationMillis).build(); - * Table afterTable = bigquery.update(tableInfo); - * } - *+ *
{@code + * String datasetName = "my_dataset_name"; + * String tableName = "my_table_name"; + * Table beforeTable = bigquery.getTable(datasetName, tableName); + * + * // Set table to expire 5 days from now. + * long expirationMillis = DateTime.now().plusDays(5).getMillis(); + * TableInfo tableInfo = beforeTable.toBuilder().setExpirationTime(expirationMillis).build(); + * Table afterTable = bigquery.update(tableInfo); + * }* * @throws BigQueryException upon failure */ @@ -1143,33 +1092,27 @@ public int hashCode() { * *
Example of updating a model by changing its description. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * String modelName = "my_model_name"; - * String newDescription = "new_description"; - * Model beforeModel = bigquery.getModel(datasetName, modelName); - * ModelInfo modelInfo = beforeModel.toBuilder().setDescription(newDescription).build(); - * Model afterModel = bigquery.update(modelInfo); - * } - *+ *
{@code + * String datasetName = "my_dataset_name"; + * String modelName = "my_model_name"; + * String newDescription = "new_description"; + * Model beforeModel = bigquery.getModel(datasetName, modelName); + * ModelInfo modelInfo = beforeModel.toBuilder().setDescription(newDescription).build(); + * Model afterModel = bigquery.update(modelInfo); + * }* *
Example of updating a model by changing its expiration. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * String modelName = "my_model_name"; - * Model beforeModel = bigquery.getModel(datasetName, modelName); - * - * // Set model to expire 5 days from now. - * long expirationMillis = DateTime.now().plusDays(5).getMillis(); - * ModelInfo modelInfo = beforeModel.toBuilder().setExpirationTime(expirationMillis).build(); - * Model afterModel = bigquery.update(modelInfo); - * } - *+ *
{@code + * String datasetName = "my_dataset_name"; + * String modelName = "my_model_name"; + * Model beforeModel = bigquery.getModel(datasetName, modelName); + * + * // Set model to expire 5 days from now. + * long expirationMillis = DateTime.now().plusDays(5).getMillis(); + * ModelInfo modelInfo = beforeModel.toBuilder().setExpirationTime(expirationMillis).build(); + * Model afterModel = bigquery.update(modelInfo); + * }* * @throws BigQueryException upon failure */ @@ -1187,14 +1130,11 @@ public int hashCode() { * *
Example of getting a table. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * String tableName = "my_table_name"; - * Table table = bigquery.getTable(datasetName, tableName); - * } - *+ *
{@code + * String datasetName = "my_dataset_name"; + * String tableName = "my_table_name"; + * Table table = bigquery.getTable(datasetName, tableName); + * }* * @throws BigQueryException upon failure */ @@ -1205,16 +1145,13 @@ public int hashCode() { * *
Example of getting a table. * - *
- * { - * @code - * String projectId = "my_project_id"; - * String datasetName = "my_dataset_name"; - * String tableName = "my_table_name"; - * TableId tableId = TableId.of(projectId, datasetName, tableName); - * Table table = bigquery.getTable(tableId); - * } - *+ *
{@code + * String projectId = "my_project_id"; + * String datasetName = "my_dataset_name"; + * String tableName = "my_table_name"; + * TableId tableId = TableId.of(projectId, datasetName, tableName); + * Table table = bigquery.getTable(tableId); + * }* * @throws BigQueryException upon failure */ @@ -1232,16 +1169,13 @@ public int hashCode() { * *
Example of getting a model. * - *
- * { - * @code - * String projectId = "my_project_id"; - * String datasetName = "my_dataset_name"; - * String modelName = "my_model_name"; - * ModelId modelId = ModelId.of(projectId, datasetName, tableName); - * Model model = bigquery.getModel(modelId); - * } - *+ *
{@code + * String projectId = "my_project_id"; + * String datasetName = "my_dataset_name"; + * String modelName = "my_model_name"; + * ModelId modelId = ModelId.of(projectId, datasetName, tableName); + * Model model = bigquery.getModel(modelId); + * }* * @throws BigQueryException upon failure */ @@ -1275,16 +1209,13 @@ public int hashCode() { * *
Example of listing the tables in a dataset, specifying the page size. * - *
- * { - * @code - * String datasetName = "my_dataset_name"; - * Page<Table> tables = bigquery.listTables(datasetName, TableListOption.pageSize(100)); - * for (Table table : tables.iterateAll()) { - * // do something with the table - * } + *{@code + * String datasetName = "my_dataset_name"; + * Page