From 342573ad1067c6b6ebb6d8dd66a8abc29e69bef6 Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Mon, 8 Jun 2020 15:14:08 -0400 Subject: [PATCH] chore: run code formatter (#425) --- .../example/bigquery/AddColumnLoadAppend.java | 11 +++++---- .../com/example/bigquery/BrowseTable.java | 16 ++++++------- .../java/com/example/bigquery/CopyTable.java | 12 +++++----- .../bigquery/CreateClusteredTable.java | 17 ++++++-------- .../bigquery/CreatePartitionedTable.java | 8 +++---- .../example/bigquery/ExtractTableToCsv.java | 9 +++++--- .../example/bigquery/ExtractTableToJson.java | 9 +++++--- .../com/example/bigquery/LoadLocalFile.java | 8 +++---- .../bigquery/LoadParquetReplaceTable.java | 4 ++-- .../example/bigquery/LoadTableClustered.java | 23 +++++++++++-------- .../example/bigquery/SaveQueryToTable.java | 7 +++--- .../com/example/bigquery/SimpleQuery.java | 3 +-- .../com/example/bigquery/TableInsertRows.java | 4 ++-- .../com/example/bigquery/UpdateTableDML.java | 21 +++++++++-------- .../bigquery/UpdateTableDescription.java | 4 ++-- .../bigquery/UpdateTableExpiration.java | 4 ++-- .../bigquery/AddColumnLoadAppendIT.java | 3 ++- .../com/example/bigquery/BrowseTableIT.java | 1 - .../com/example/bigquery/CopyTableIT.java | 20 +++++++++------- .../bigquery/CreateClusteredTableIT.java | 12 +++++----- .../bigquery/CreatePartitionedTableIT.java | 8 +++---- .../example/bigquery/ExtractTableToCsvIT.java | 4 ++-- .../bigquery/ExtractTableToJsonIT.java | 4 ++-- .../bigquery/LoadTableClusteredIT.java | 12 +++++----- .../example/bigquery/SaveQueryToTableIT.java | 4 +--- .../com/example/bigquery/SimpleQueryIT.java | 3 +-- .../example/bigquery/UpdateTableDMLIT.java | 6 ++--- .../bigquery/UpdateTableDescriptionIT.java | 2 -- .../bigquery/UpdateTableExpirationIT.java | 6 ++--- 29 files changed, 124 insertions(+), 121 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/bigquery/AddColumnLoadAppend.java b/samples/snippets/src/main/java/com/example/bigquery/AddColumnLoadAppend.java index 932c27d69..a8b22ed8b 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/AddColumnLoadAppend.java +++ b/samples/snippets/src/main/java/com/example/bigquery/AddColumnLoadAppend.java @@ -47,14 +47,15 @@ public static void runAddColumnLoadAppend() throws Exception { // 'REQUIRED' fields cannot be added to an existing schema, so the additional column must be // 'NULLABLE'. Schema schema = - Schema.of( - Field.newBuilder("name", LegacySQLTypeName.STRING) + Schema.of( + Field.newBuilder("name", LegacySQLTypeName.STRING) .setMode(Field.Mode.REQUIRED) .build()); List fields = schema.getFields(); // Adding below additional column during the load job - Field newField = Field.newBuilder("post_abbr", LegacySQLTypeName.STRING) + Field newField = + Field.newBuilder("post_abbr", LegacySQLTypeName.STRING) .setMode(Field.Mode.NULLABLE) .build(); List newFields = new ArrayList<>(fields); @@ -63,8 +64,8 @@ public static void runAddColumnLoadAppend() throws Exception { addColumnLoadAppend(datasetName, tableName, sourceUri, newSchema); } - public static void addColumnLoadAppend(String datasetName, String tableName, - String sourceUri, Schema newSchema) throws Exception { + public static void addColumnLoadAppend( + String datasetName, String tableName, String sourceUri, Schema newSchema) throws Exception { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. diff --git a/samples/snippets/src/main/java/com/example/bigquery/BrowseTable.java b/samples/snippets/src/main/java/com/example/bigquery/BrowseTable.java index 7228dfb6e..518067e77 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/BrowseTable.java +++ b/samples/snippets/src/main/java/com/example/bigquery/BrowseTable.java @@ -44,16 +44,16 @@ public static void browseTable(String dataset, String table) { TableId tableId = TableId.of(dataset, table); // Page over 100 records. If you don't need pagination, remove the pageSize parameter. - TableResult result = - bigquery.listTableData(tableId, TableDataListOption.pageSize(100)); + TableResult result = bigquery.listTableData(tableId, TableDataListOption.pageSize(100)); // Print the records - result.iterateAll().forEach(row -> { - row.forEach(fieldValue -> - System.out.print(fieldValue.toString() + ", ") - ); - System.out.println(); - }); + result + .iterateAll() + .forEach( + row -> { + row.forEach(fieldValue -> System.out.print(fieldValue.toString() + ", ")); + System.out.println(); + }); System.out.println("Query ran successfully"); } catch (BigQueryException e) { diff --git a/samples/snippets/src/main/java/com/example/bigquery/CopyTable.java b/samples/snippets/src/main/java/com/example/bigquery/CopyTable.java index 6c780c8d7..9ac960f79 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/CopyTable.java +++ b/samples/snippets/src/main/java/com/example/bigquery/CopyTable.java @@ -37,8 +37,11 @@ public static void runCopyTable() { copyTable(sourceDatasetName, sourceTableId, destinationDatasetName, destinationTableId); } - public static void copyTable(String sourceDatasetName, String sourceTableId, - String destinationDatasetName, String destinationTableId) { + public static void copyTable( + String sourceDatasetName, + String sourceTableId, + String destinationDatasetName, + String destinationTableId) { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. @@ -50,10 +53,7 @@ public static void copyTable(String sourceDatasetName, String sourceTableId, // For more information on CopyJobConfiguration see: // https://googleapis.dev/java/google-cloud-clients/latest/com/google/cloud/bigquery/JobConfiguration.html CopyJobConfiguration configuration = - CopyJobConfiguration.newBuilder( - destinationTable, - sourceTable - ).build(); + CopyJobConfiguration.newBuilder(destinationTable, sourceTable).build(); // For more information on Job see: // https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/bigquery/package-summary.html diff --git a/samples/snippets/src/main/java/com/example/bigquery/CreateClusteredTable.java b/samples/snippets/src/main/java/com/example/bigquery/CreateClusteredTable.java index 27a0e144f..602fbfedd 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/CreateClusteredTable.java +++ b/samples/snippets/src/main/java/com/example/bigquery/CreateClusteredTable.java @@ -37,17 +37,15 @@ public static void runCreateClusteredTable() { String datasetName = "MY_DATASET_NAME"; String tableName = "MY_TABLE_NAME"; Schema schema = - Schema.of( - Field.of("name", StandardSQLTypeName.STRING), - Field.of("post_abbr", StandardSQLTypeName.STRING), - Field.of("date", StandardSQLTypeName.DATE)); - createClusteredTable(datasetName, tableName, - schema, ImmutableList.of("name", "post_abbr")); + Schema.of( + Field.of("name", StandardSQLTypeName.STRING), + Field.of("post_abbr", StandardSQLTypeName.STRING), + Field.of("date", StandardSQLTypeName.DATE)); + createClusteredTable(datasetName, tableName, schema, ImmutableList.of("name", "post_abbr")); } public static void createClusteredTable( - String datasetName, String tableName, - Schema schema, List clusteringFields) { + String datasetName, String tableName, Schema schema, List clusteringFields) { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. @@ -58,8 +56,7 @@ public static void createClusteredTable( TimePartitioning partitioning = TimePartitioning.of(TimePartitioning.Type.DAY); // Clustering fields will be consisted of fields mentioned in the schema. // As of now, another condition is that the table should be partitioned. - Clustering clustering = - Clustering.newBuilder().setFields(clusteringFields).build(); + Clustering clustering = Clustering.newBuilder().setFields(clusteringFields).build(); StandardTableDefinition tableDefinition = StandardTableDefinition.newBuilder() diff --git a/samples/snippets/src/main/java/com/example/bigquery/CreatePartitionedTable.java b/samples/snippets/src/main/java/com/example/bigquery/CreatePartitionedTable.java index 62a51c669..1279d65ed 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/CreatePartitionedTable.java +++ b/samples/snippets/src/main/java/com/example/bigquery/CreatePartitionedTable.java @@ -35,10 +35,10 @@ public static void runCreatePartitionedTable() { String datasetName = "MY_DATASET_NAME"; String tableName = "MY_TABLE_NAME"; Schema schema = - Schema.of( - Field.of("stringField", StandardSQLTypeName.STRING), - Field.of("booleanField", StandardSQLTypeName.BOOL), - Field.of("dateField", StandardSQLTypeName.DATE)); + Schema.of( + Field.of("stringField", StandardSQLTypeName.STRING), + Field.of("booleanField", StandardSQLTypeName.BOOL), + Field.of("dateField", StandardSQLTypeName.DATE)); createPartitionedTable(datasetName, tableName, schema); } diff --git a/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToCsv.java b/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToCsv.java index 5aada2764..6c6701f84 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToCsv.java +++ b/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToCsv.java @@ -46,7 +46,10 @@ public static void runExtractTableToCsv() { // Exports datasetName:tableName to destinationUri as raw CSV public static void extractTableToCsv( - String projectId, String datasetName, String tableName, String destinationUri, + String projectId, + String datasetName, + String tableName, + String destinationUri, String dataFormat) { try { // Initialize client that will be used to send requests. This client only needs to be created @@ -71,8 +74,8 @@ public static void extractTableToCsv( "BigQuery was unable to extract due to an error: \n" + job.getStatus().getError()); return; } - System.out.println("Table export successful. Check in GCS bucket for the " + - dataFormat + " file."); + System.out.println( + "Table export successful. Check in GCS bucket for the " + dataFormat + " file."); } catch (BigQueryException | InterruptedException e) { System.out.println("Table extraction job was interrupted. \n" + e.toString()); } diff --git a/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToJson.java b/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToJson.java index 6d5586d7a..6db988703 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToJson.java +++ b/samples/snippets/src/main/java/com/example/bigquery/ExtractTableToJson.java @@ -50,7 +50,10 @@ public static void runExtractTableToJson() { // Exports datasetName:tableName to destinationUri as a JSON file public static void extractTableToJson( - String projectId, String datasetName, String tableName, String destinationUri, + String projectId, + String datasetName, + String tableName, + String destinationUri, String dataFormat) { try { // Initialize client that will be used to send requests. This client only needs to be created @@ -75,8 +78,8 @@ public static void extractTableToJson( "BigQuery was unable to extract due to an error: \n" + job.getStatus().getError()); return; } - System.out.println("Table export successful. Check in GCS bucket for the " + - dataFormat + " file."); + System.out.println( + "Table export successful. Check in GCS bucket for the " + dataFormat + " file."); } catch (BigQueryException | InterruptedException e) { System.out.println("Table extraction job was interrupted. \n" + e.toString()); } diff --git a/samples/snippets/src/main/java/com/example/bigquery/LoadLocalFile.java b/samples/snippets/src/main/java/com/example/bigquery/LoadLocalFile.java index 3e580ec7d..98257420e 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/LoadLocalFile.java +++ b/samples/snippets/src/main/java/com/example/bigquery/LoadLocalFile.java @@ -44,8 +44,8 @@ public static void runLoadLocalFile() throws IOException, InterruptedException { loadLocalFile(datasetName, tableName, csvPath, FormatOptions.csv()); } - public static void loadLocalFile(String datasetName, String tableName, Path csvPath, - FormatOptions formatOptions) + public static void loadLocalFile( + String datasetName, String tableName, Path csvPath, FormatOptions formatOptions) throws IOException, InterruptedException { try { // Initialize client that will be used to send requests. This client only needs to be created @@ -54,9 +54,7 @@ public static void loadLocalFile(String datasetName, String tableName, Path csvP TableId tableId = TableId.of(datasetName, tableName); WriteChannelConfiguration writeChannelConfiguration = - WriteChannelConfiguration.newBuilder(tableId) - .setFormatOptions(formatOptions) - .build(); + WriteChannelConfiguration.newBuilder(tableId).setFormatOptions(formatOptions).build(); // The location and JobName must be specified; other fields can be auto-detected. String jobName = "jobId_" + UUID.randomUUID().toString(); diff --git a/samples/snippets/src/main/java/com/example/bigquery/LoadParquetReplaceTable.java b/samples/snippets/src/main/java/com/example/bigquery/LoadParquetReplaceTable.java index c8ee67c67..eb09015fa 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/LoadParquetReplaceTable.java +++ b/samples/snippets/src/main/java/com/example/bigquery/LoadParquetReplaceTable.java @@ -39,8 +39,8 @@ public static void runLoadParquetReplaceTable() { loadParquetReplaceTable(datasetName, tableName, sourceUri); } - public static void loadParquetReplaceTable(String datasetName, String tableName, - String sourceUri) { + public static void loadParquetReplaceTable( + String datasetName, String tableName, String sourceUri) { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. diff --git a/samples/snippets/src/main/java/com/example/bigquery/LoadTableClustered.java b/samples/snippets/src/main/java/com/example/bigquery/LoadTableClustered.java index 20f4104f9..a3e024518 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/LoadTableClustered.java +++ b/samples/snippets/src/main/java/com/example/bigquery/LoadTableClustered.java @@ -41,16 +41,20 @@ public static void runLoadTableClustered() throws Exception { String tableName = "MY_TABLE_NAME"; String sourceUri = "/path/to/file.csv"; Schema schema = - Schema.of( - Field.of("name", StandardSQLTypeName.STRING), - Field.of("post_abbr", StandardSQLTypeName.STRING), - Field.of("date", StandardSQLTypeName.DATE)); - loadTableClustered(datasetName, tableName, sourceUri, - schema, ImmutableList.of("name", "post_abbr")); + Schema.of( + Field.of("name", StandardSQLTypeName.STRING), + Field.of("post_abbr", StandardSQLTypeName.STRING), + Field.of("date", StandardSQLTypeName.DATE)); + loadTableClustered( + datasetName, tableName, sourceUri, schema, ImmutableList.of("name", "post_abbr")); } - public static void loadTableClustered(String datasetName, String tableName, String sourceUri, - Schema schema, List clusteringFields) + public static void loadTableClustered( + String datasetName, + String tableName, + String sourceUri, + Schema schema, + List clusteringFields) throws Exception { try { // Initialize client that will be used to send requests. This client only needs to be created @@ -62,8 +66,7 @@ public static void loadTableClustered(String datasetName, String tableName, Stri TimePartitioning partitioning = TimePartitioning.of(TimePartitioning.Type.DAY); // Clustering fields will be consisted of fields mentioned in the schema. // As of now, another condition is that the table should be partitioned. - Clustering clustering = - Clustering.newBuilder().setFields(clusteringFields).build(); + Clustering clustering = Clustering.newBuilder().setFields(clusteringFields).build(); LoadJobConfiguration loadJobConfig = LoadJobConfiguration.builder(tableId, sourceUri) diff --git a/samples/snippets/src/main/java/com/example/bigquery/SaveQueryToTable.java b/samples/snippets/src/main/java/com/example/bigquery/SaveQueryToTable.java index b160d49c0..5e346b937 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/SaveQueryToTable.java +++ b/samples/snippets/src/main/java/com/example/bigquery/SaveQueryToTable.java @@ -27,16 +27,15 @@ public class SaveQueryToTable { public static void runSaveQueryToTable() { // TODO(developer): Replace these variables before running the sample. - String query = - "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; + String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; String destinationTable = "MY_TABLE"; String destinationDataset = "MY_DATASET"; saveQueryToTable(destinationDataset, destinationTable, query); } - public static void saveQueryToTable(String destinationDataset, - String destinationTableId, String query) { + public static void saveQueryToTable( + String destinationDataset, String destinationTableId, String query) { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. diff --git a/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java b/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java index 63a1a6475..587a7456d 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java +++ b/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java @@ -38,8 +38,7 @@ public static void simpleQuery(String query) { BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); // Create the query job. - QueryJobConfiguration queryConfig = - QueryJobConfiguration.newBuilder(query).build(); + QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query).build(); // Execute the query. TableResult result = bigquery.query(queryConfig); diff --git a/samples/snippets/src/main/java/com/example/bigquery/TableInsertRows.java b/samples/snippets/src/main/java/com/example/bigquery/TableInsertRows.java index b601c859b..04fa0a2c8 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/TableInsertRows.java +++ b/samples/snippets/src/main/java/com/example/bigquery/TableInsertRows.java @@ -42,8 +42,8 @@ public static void runTableInsertRows() { tableInsertRows(datasetName, tableName, rowContent); } - public static void tableInsertRows(String datasetName, String tableName, - Map rowContent) { + public static void tableInsertRows( + String datasetName, String tableName, Map rowContent) { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. diff --git a/samples/snippets/src/main/java/com/example/bigquery/UpdateTableDML.java b/samples/snippets/src/main/java/com/example/bigquery/UpdateTableDML.java index 48f93c787..b5d5de8bc 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/UpdateTableDML.java +++ b/samples/snippets/src/main/java/com/example/bigquery/UpdateTableDML.java @@ -24,7 +24,6 @@ import com.google.cloud.bigquery.Job; import com.google.cloud.bigquery.JobId; import com.google.cloud.bigquery.QueryJobConfiguration; -import com.google.cloud.bigquery.QueryParameterValue; import com.google.cloud.bigquery.TableDataWriteChannel; import com.google.cloud.bigquery.TableId; import com.google.cloud.bigquery.TableResult; @@ -63,7 +62,8 @@ public static void updateTableDML(String datasetName, String tableName) .build(); // Imports a local JSON file into a table. - Path jsonPath = FileSystems.getDefault().getPath("src/test/resources", "userSessionsData.json"); + Path jsonPath = + FileSystems.getDefault().getPath("src/test/resources", "userSessionsData.json"); // The location and JobName must be specified; other fields can be auto-detected. String jobName = "jobId_" + UUID.randomUUID().toString(); @@ -87,16 +87,19 @@ public static void updateTableDML(String datasetName, String tableName) return; } - System.out.println(job.getStatistics().toString() + " userSessionsData json uploaded successfully"); + System.out.println( + job.getStatistics().toString() + " userSessionsData json uploaded successfully"); // Write a DML query to modify UserSessions table // To create DML query job to mask the last octet in every row's ip_address column - String dmlQuery = String.format("UPDATE `%s.%s` \n" - + "SET ip_address = REGEXP_REPLACE(ip_address, r\"(\\.[0-9]+)$\", \".0\")\n" - + "WHERE TRUE", datasetName, tableName); + String dmlQuery = + String.format( + "UPDATE `%s.%s` \n" + + "SET ip_address = REGEXP_REPLACE(ip_address, r\"(\\.[0-9]+)$\", \".0\")\n" + + "WHERE TRUE", + datasetName, tableName); - QueryJobConfiguration dmlQueryConfig = - QueryJobConfiguration.newBuilder(dmlQuery).build(); + QueryJobConfiguration dmlQueryConfig = QueryJobConfiguration.newBuilder(dmlQuery).build(); // Execute the query. TableResult result = bigquery.query(dmlQueryConfig); @@ -110,4 +113,4 @@ public static void updateTableDML(String datasetName, String tableName) } } } -// [END bigquery_update_with_dml] \ No newline at end of file +// [END bigquery_update_with_dml] diff --git a/samples/snippets/src/main/java/com/example/bigquery/UpdateTableDescription.java b/samples/snippets/src/main/java/com/example/bigquery/UpdateTableDescription.java index c52df00c6..55c6af53d 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/UpdateTableDescription.java +++ b/samples/snippets/src/main/java/com/example/bigquery/UpdateTableDescription.java @@ -32,8 +32,8 @@ public static void runUpdateTableDescription() { updateTableDescription(datasetName, tableName, newDescription); } - public static void updateTableDescription(String datasetName, String tableName, - String newDescription) { + public static void updateTableDescription( + String datasetName, String tableName, String newDescription) { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. diff --git a/samples/snippets/src/main/java/com/example/bigquery/UpdateTableExpiration.java b/samples/snippets/src/main/java/com/example/bigquery/UpdateTableExpiration.java index cbc9a1940..b3e369bff 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/UpdateTableExpiration.java +++ b/samples/snippets/src/main/java/com/example/bigquery/UpdateTableExpiration.java @@ -34,8 +34,8 @@ public static void runUpdateTableExpiration() { updateTableExpiration(datasetName, tableName, newExpiration); } - public static void updateTableExpiration(String datasetName, String tableName, - Long newExpiration) { + public static void updateTableExpiration( + String datasetName, String tableName, Long newExpiration) { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. diff --git a/samples/snippets/src/test/java/com/example/bigquery/AddColumnLoadAppendIT.java b/samples/snippets/src/test/java/com/example/bigquery/AddColumnLoadAppendIT.java index afbe13c94..b4b3751f7 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/AddColumnLoadAppendIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/AddColumnLoadAppendIT.java @@ -75,7 +75,8 @@ public void testAddColumnLoadAppend() throws Exception { List fields = originalSchema.getFields(); // Adding below additional column during the load job - Field newField = Field.newBuilder("post_abbr", LegacySQLTypeName.STRING) + Field newField = + Field.newBuilder("post_abbr", LegacySQLTypeName.STRING) .setMode(Field.Mode.NULLABLE) .build(); List newFields = new ArrayList<>(fields); diff --git a/samples/snippets/src/test/java/com/example/bigquery/BrowseTableIT.java b/samples/snippets/src/test/java/com/example/bigquery/BrowseTableIT.java index b88a15e66..f7bc16c67 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/BrowseTableIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/BrowseTableIT.java @@ -76,6 +76,5 @@ public void testBrowseTable() { // Clean up DeleteTable.deleteTable(BIGQUERY_DATASET_NAME, tableName); - } } diff --git a/samples/snippets/src/test/java/com/example/bigquery/CopyTableIT.java b/samples/snippets/src/test/java/com/example/bigquery/CopyTableIT.java index 1ca1f42c5..18a2529ed 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/CopyTableIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/CopyTableIT.java @@ -61,13 +61,14 @@ public void tearDown() { @Test public void testCopyTable() { - // Create a new destination and source table for each test since existing table cannot be overwritten - String generatedDestTableName = "gcloud_test_table_temp_" + - UUID.randomUUID().toString().replace('-', '_'); - String generatedSourceTableName = "gcloud_test_table_temp_" + - UUID.randomUUID().toString().replace('-', '_'); + // Create a new destination and source table for each test since existing table cannot be + // overwritten + String generatedDestTableName = + "gcloud_test_table_temp_" + UUID.randomUUID().toString().replace('-', '_'); + String generatedSourceTableName = + "gcloud_test_table_temp_" + UUID.randomUUID().toString().replace('-', '_'); - //Adding an arbitrary table schema so we aren't copying nothing. + // Adding an arbitrary table schema so we aren't copying nothing. Schema schema = Schema.of( Field.of("stringField", StandardSQLTypeName.STRING), @@ -76,8 +77,11 @@ public void testCopyTable() { CreateTable.createTable(BIGQUERY_DATASET_NAME, generatedDestTableName, schema); CreateTable.createTable(BIGQUERY_DATASET_NAME, generatedSourceTableName, schema); - CopyTable.copyTable(BIGQUERY_DATASET_NAME, generatedSourceTableName, - BIGQUERY_DATASET_NAME, generatedDestTableName); + CopyTable.copyTable( + BIGQUERY_DATASET_NAME, + generatedSourceTableName, + BIGQUERY_DATASET_NAME, + generatedDestTableName); assertThat(bout.toString()).contains("Table copied successfully."); // Clean up diff --git a/samples/snippets/src/test/java/com/example/bigquery/CreateClusteredTableIT.java b/samples/snippets/src/test/java/com/example/bigquery/CreateClusteredTableIT.java index 37ddd226b..26e45c83d 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/CreateClusteredTableIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/CreateClusteredTableIT.java @@ -63,13 +63,13 @@ public void tearDown() { public void createClusteredTable() { String tableName = "MY_CLUSTERED_TABLE"; Schema schema = - Schema.of( - Field.of("name", StandardSQLTypeName.STRING), - Field.of("post_abbr", StandardSQLTypeName.STRING), - Field.of("date", StandardSQLTypeName.DATE)); + Schema.of( + Field.of("name", StandardSQLTypeName.STRING), + Field.of("post_abbr", StandardSQLTypeName.STRING), + Field.of("date", StandardSQLTypeName.DATE)); - CreateClusteredTable.createClusteredTable(BIGQUERY_DATASET_NAME, tableName, - schema, ImmutableList.of("name", "post_abbr")); + CreateClusteredTable.createClusteredTable( + BIGQUERY_DATASET_NAME, tableName, schema, ImmutableList.of("name", "post_abbr")); assertThat(bout.toString()).contains("Clustered table created successfully"); diff --git a/samples/snippets/src/test/java/com/example/bigquery/CreatePartitionedTableIT.java b/samples/snippets/src/test/java/com/example/bigquery/CreatePartitionedTableIT.java index 32000c5ce..35ab85b38 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/CreatePartitionedTableIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/CreatePartitionedTableIT.java @@ -62,10 +62,10 @@ public void tearDown() { public void testCreatePartitionedTable() { String tableName = "MY_PARTITIONED_TABLE"; Schema schema = - Schema.of( - Field.of("stringField", StandardSQLTypeName.STRING), - Field.of("booleanField", StandardSQLTypeName.BOOL), - Field.of("dateField", StandardSQLTypeName.DATE)); + Schema.of( + Field.of("stringField", StandardSQLTypeName.STRING), + Field.of("booleanField", StandardSQLTypeName.BOOL), + Field.of("dateField", StandardSQLTypeName.DATE)); CreatePartitionedTable.createPartitionedTable(BIGQUERY_DATASET_NAME, tableName, schema); diff --git a/samples/snippets/src/test/java/com/example/bigquery/ExtractTableToCsvIT.java b/samples/snippets/src/test/java/com/example/bigquery/ExtractTableToCsvIT.java index d0d763387..457bb5fb7 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/ExtractTableToCsvIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/ExtractTableToCsvIT.java @@ -64,8 +64,8 @@ public void testExtractTableToJson() { String dataFormat = "CSV"; // Extract table content to GCS in CSV format - ExtractTableToCsv.extractTableToCsv(projectId, datasetName, tableName, destinationUri, - dataFormat); + ExtractTableToCsv.extractTableToCsv( + projectId, datasetName, tableName, destinationUri, dataFormat); assertThat(bout.toString()) .contains("Table export successful. Check in GCS bucket for the " + dataFormat + " file."); } diff --git a/samples/snippets/src/test/java/com/example/bigquery/ExtractTableToJsonIT.java b/samples/snippets/src/test/java/com/example/bigquery/ExtractTableToJsonIT.java index 9207f5965..8d5764b18 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/ExtractTableToJsonIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/ExtractTableToJsonIT.java @@ -66,8 +66,8 @@ public void testExtractTableToJson() { String dataFormat = FormatOptions.json().toString(); // Extract table content to GCS in JSON format - ExtractTableToJson.extractTableToJson(projectId, datasetName, tableName, destinationUri, - dataFormat); + ExtractTableToJson.extractTableToJson( + projectId, datasetName, tableName, destinationUri, dataFormat); assertThat(bout.toString()) .contains("Table export successful. Check in GCS bucket for the " + dataFormat + " file."); } diff --git a/samples/snippets/src/test/java/com/example/bigquery/LoadTableClusteredIT.java b/samples/snippets/src/test/java/com/example/bigquery/LoadTableClusteredIT.java index 98ef57afd..3c05c7285 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/LoadTableClusteredIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/LoadTableClusteredIT.java @@ -66,13 +66,13 @@ public void loadTableClustered() throws Exception { String tableName = "LOAD_CLUSTERED_TABLE_TEST"; Schema schema = - Schema.of( - Field.of("name", StandardSQLTypeName.STRING), - Field.of("post_abbr", StandardSQLTypeName.STRING), - Field.of("date", StandardSQLTypeName.DATE)); + Schema.of( + Field.of("name", StandardSQLTypeName.STRING), + Field.of("post_abbr", StandardSQLTypeName.STRING), + Field.of("date", StandardSQLTypeName.DATE)); - LoadTableClustered.loadTableClustered(BIGQUERY_DATASET_NAME, tableName, sourceUri, - schema, ImmutableList.of("name", "post_abbr")); + LoadTableClustered.loadTableClustered( + BIGQUERY_DATASET_NAME, tableName, sourceUri, schema, ImmutableList.of("name", "post_abbr")); assertThat(bout.toString()) .contains("Data successfully loaded into clustered table during load job"); diff --git a/samples/snippets/src/test/java/com/example/bigquery/SaveQueryToTableIT.java b/samples/snippets/src/test/java/com/example/bigquery/SaveQueryToTableIT.java index f0b1d244e..3552c2c90 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/SaveQueryToTableIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/SaveQueryToTableIT.java @@ -31,7 +31,6 @@ public class SaveQueryToTableIT { private ByteArrayOutputStream bout; private PrintStream out; - private static final String BIGQUERY_DATASET_NAME = System.getenv("BIGQUERY_DATASET_NAME"); private static void requireEnvVar(String varName) { @@ -60,8 +59,7 @@ public void tearDown() { @Test public void testSaveQueryToTable() { String tableName = "MY_TABLE_NAME_" + UUID.randomUUID().toString().replace("-", "_"); - String query = - "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; + String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; SaveQueryToTable.saveQueryToTable(BIGQUERY_DATASET_NAME, tableName, query); diff --git a/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java b/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java index 76428faab..8ee67edde 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java @@ -42,8 +42,7 @@ public void tearDown() { @Test public void testSimpleQuery() { - String query = - "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; + String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; SimpleQuery.simpleQuery(query); assertThat(bout.toString()).contains("Query ran successfully"); diff --git a/samples/snippets/src/test/java/com/example/bigquery/UpdateTableDMLIT.java b/samples/snippets/src/test/java/com/example/bigquery/UpdateTableDMLIT.java index 841ebca98..006ba13ce 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/UpdateTableDMLIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/UpdateTableDMLIT.java @@ -25,8 +25,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; -import java.nio.file.FileSystems; -import java.nio.file.Path; import java.util.UUID; import org.junit.After; import org.junit.Before; @@ -42,7 +40,7 @@ public class UpdateTableDMLIT { private static final String BIGQUERY_DATASET_NAME = requireEnvVar("BIGQUERY_DATASET_NAME"); private static String requireEnvVar(String varName) { - String value = System.getenv(varName); + String value = System.getenv(varName); assertNotNull( "Environment variable " + varName + " is required to perform these tests.", System.getenv(varName)); @@ -89,4 +87,4 @@ public void testUpdateTableDML() throws IOException, InterruptedException { UpdateTableDML.updateTableDML(BIGQUERY_DATASET_NAME, tableName); assertThat(bout.toString()).contains("Table updated successfully using DML"); } -} \ No newline at end of file +} diff --git a/samples/snippets/src/test/java/com/example/bigquery/UpdateTableDescriptionIT.java b/samples/snippets/src/test/java/com/example/bigquery/UpdateTableDescriptionIT.java index ad71373a3..f30c73e1c 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/UpdateTableDescriptionIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/UpdateTableDescriptionIT.java @@ -33,7 +33,6 @@ public class UpdateTableDescriptionIT { private static final String BIGQUERY_DATASET_NAME = System.getenv("BIGQUERY_DATASET_NAME"); - private static void requireEnvVar(String varName) { assertNotNull( "Environment variable " + varName + " is required to perform these tests.", @@ -72,6 +71,5 @@ public void updateTableDescription() { // Clean up DeleteTable.deleteTable(BIGQUERY_DATASET_NAME, tableName); - } } diff --git a/samples/snippets/src/test/java/com/example/bigquery/UpdateTableExpirationIT.java b/samples/snippets/src/test/java/com/example/bigquery/UpdateTableExpirationIT.java index 73ca93c06..abd1eb3e0 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/UpdateTableExpirationIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/UpdateTableExpirationIT.java @@ -65,9 +65,9 @@ public void updateTableExpiration() { String suffix = UUID.randomUUID().toString().replace('-', '_'); String tableName = "update_expiration_table_" + suffix; Schema schema = - Schema.of( - Field.of("stringField", StandardSQLTypeName.STRING), - Field.of("booleanField", StandardSQLTypeName.BOOL)); + Schema.of( + Field.of("stringField", StandardSQLTypeName.STRING), + Field.of("booleanField", StandardSQLTypeName.BOOL)); CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, schema); Long newExpiration = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS); UpdateTableExpiration.updateTableExpiration(BIGQUERY_DATASET_NAME, tableName, newExpiration);