Пример #1
0
 @Test
 public void testUpdateDataset() {
   Dataset dataset =
       bigquery.create(DatasetInfo.builder(OTHER_DATASET).description("Some Description").build());
   assertNotNull(dataset);
   assertEquals(bigquery.options().projectId(), dataset.datasetId().project());
   assertEquals(OTHER_DATASET, dataset.datasetId().dataset());
   assertEquals("Some Description", dataset.description());
   Dataset updatedDataset =
       bigquery.update(dataset.toBuilder().description("Updated Description").build());
   assertEquals("Updated Description", updatedDataset.description());
   assertTrue(dataset.delete());
 }
Пример #2
0
 @Test
 public void testUpdateTable() {
   String tableName = "test_update_table";
   StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
   TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
   Table createdTable = bigquery.create(tableInfo);
   assertNotNull(createdTable);
   Table updatedTable =
       bigquery.update(tableInfo.toBuilder().description("newDescription").build());
   assertEquals(DATASET, updatedTable.tableId().dataset());
   assertEquals(tableName, updatedTable.tableId().table());
   assertEquals(TABLE_SCHEMA, updatedTable.definition().schema());
   assertEquals("newDescription", updatedTable.description());
   assertTrue(updatedTable.delete());
 }
Пример #3
0
 @Test
 public void testUpdateNonExistingTable() {
   TableInfo tableInfo =
       TableInfo.of(
           TableId.of(DATASET, "test_update_non_existing_table"),
           StandardTableDefinition.of(SIMPLE_SCHEMA));
   try {
     bigquery.update(tableInfo);
     fail("BigQueryException was expected");
   } catch (BigQueryException e) {
     BigQueryError error = e.error();
     assertNotNull(error);
     assertEquals("notFound", error.reason());
     assertNotNull(error.message());
   }
 }
Пример #4
0
 @Test
 public void testUpdateTableWithSelectedFields() {
   String tableName = "test_update_with_selected_fields_table";
   StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
   TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
   Table createdTable = bigquery.create(tableInfo);
   assertNotNull(createdTable);
   Table updatedTable =
       bigquery.update(
           tableInfo.toBuilder().description("newDescr").build(),
           TableOption.fields(TableField.DESCRIPTION));
   assertTrue(updatedTable.definition() instanceof StandardTableDefinition);
   assertEquals(DATASET, updatedTable.tableId().dataset());
   assertEquals(tableName, updatedTable.tableId().table());
   assertEquals("newDescr", updatedTable.description());
   assertNull(updatedTable.definition().schema());
   assertNull(updatedTable.lastModifiedTime());
   assertNull(updatedTable.<StandardTableDefinition>definition().numBytes());
   assertNull(updatedTable.<StandardTableDefinition>definition().numRows());
   assertTrue(createdTable.delete());
 }
Пример #5
0
 @Test
 public void testUpdateDatasetWithSelectedFields() {
   Dataset dataset =
       bigquery.create(DatasetInfo.builder(OTHER_DATASET).description("Some Description").build());
   assertNotNull(dataset);
   assertEquals(bigquery.options().projectId(), dataset.datasetId().project());
   assertEquals(OTHER_DATASET, dataset.datasetId().dataset());
   assertEquals("Some Description", dataset.description());
   Dataset updatedDataset =
       bigquery.update(
           dataset.toBuilder().description("Updated Description").build(),
           DatasetOption.fields(DatasetField.DESCRIPTION));
   assertEquals("Updated Description", updatedDataset.description());
   assertNull(updatedDataset.creationTime());
   assertNull(updatedDataset.defaultTableLifetime());
   assertNull(updatedDataset.acl());
   assertNull(updatedDataset.etag());
   assertNull(updatedDataset.friendlyName());
   assertNull(updatedDataset.id());
   assertNull(updatedDataset.lastModified());
   assertNull(updatedDataset.location());
   assertNull(updatedDataset.selfLink());
   assertTrue(dataset.delete());
 }