use of com.google.api.services.bigquery.model.TableList in project google-cloud-java by GoogleCloudPlatform.
the class HttpBigQueryRpc method listTables.
@Override
public Tuple<String, Iterable<Table>> listTables(String projectId, String datasetId, Map<Option, ?> options) {
try {
TableList tableList = bigquery.tables().list(projectId, datasetId).setMaxResults(Option.MAX_RESULTS.getLong(options)).setPageToken(Option.PAGE_TOKEN.getString(options)).execute();
Iterable<TableList.Tables> tables = tableList.getTables();
return Tuple.of(tableList.getNextPageToken(), Iterables.transform(tables != null ? tables : ImmutableList.<TableList.Tables>of(), new Function<TableList.Tables, Table>() {
@Override
public Table apply(TableList.Tables tablePb) {
return new Table().setFriendlyName(tablePb.getFriendlyName()).setId(tablePb.getId()).setKind(tablePb.getKind()).setTableReference(tablePb.getTableReference()).setType(tablePb.getType());
}
}));
} catch (IOException ex) {
throw translate(ex);
}
}
use of com.google.api.services.bigquery.model.TableList in project beam by apache.
the class BigqueryClient method deleteDataset.
public void deleteDataset(String projectId, String datasetId) {
try {
TableList tables = bqClient.tables().list(projectId, datasetId).execute();
for (Tables table : tables.getTables()) {
this.deleteTable(projectId, datasetId, table.getTableReference().getTableId());
}
} catch (Exception e) {
LOG.debug("Exceptions caught when listing all tables: " + e.getMessage());
}
try {
bqClient.datasets().delete(projectId, datasetId).execute();
LOG.info("Successfully deleted dataset: " + datasetId);
} catch (Exception e) {
LOG.debug("Exceptions caught when deleting dataset: " + e.getMessage());
}
}
Aggregations