/** * Updates the table's information. Dataset's and table's user-defined ids cannot be changed. A * new {@code Table} object is returned. * * @param tableInfo new table's information. Dataset's and table's user-defined ids must match the * ones of the current table * @param options dataset options * @return a {@code Table} object with updated information * @throws BigQueryException upon failure */ public Table update(BaseTableInfo tableInfo, BigQuery.TableOption... options) { checkArgument( Objects.equals(tableInfo.tableId().dataset(), info.tableId().dataset()), "Dataset's user-defined ids must match"); checkArgument( Objects.equals(tableInfo.tableId().table(), info.tableId().table()), "Table's user-defined ids must match"); return new Table(bigquery, bigquery.update(tableInfo, options)); }
@Test public void testUpdateWithOptions() throws Exception { BaseTableInfo updatedInfo = TABLE_INFO.toBuilder().description("Description").build(); expect(bigquery.update(updatedInfo, BigQuery.TableOption.fields())).andReturn(updatedInfo); replay(bigquery); Table updatedTable = table.update(updatedInfo, BigQuery.TableOption.fields()); assertSame(bigquery, updatedTable.bigquery()); assertEquals(updatedInfo, updatedTable.info()); }