.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(),
private static void listTables(Bigquery service, String projectNumber, String datasetId) throws IOException { Bigquery.Tables.List listTablesReply = service.tables().list(projectNumber, datasetId); TableList tableList = listTablesReply.execute(); if (tableList.getTables() != null) { List tables = tableList.getTables(); System.out.println("Tables list:"); for (TableList.Tables table : tables) { System.out.format("%s\n", table.getId()); } } }
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()); } }
private void deleteTables(String projectId, String datasetId) throws IOException { Bigquery.Tables.List list = client.tables().list(projectId, datasetId); TableList tableList; do { tableList = list.execute(); List<TableList.Tables> tables = tableList.getTables(); if (tables != null) { for (TableList.Tables table : tables) { deleteTable(projectId, datasetId, table.getTableReference().getTableId()); } } } while (tableList.getNextPageToken() != null); }
.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(),
@Override public Tuple<String, Iterable<Table>> listTables(String datasetId, Map<Option, ?> options) { try { TableList tableList = bigquery.tables() .list(this.options.projectId(), datasetId) .setMaxResults(MAX_RESULTS.getLong(options)) .setPageToken(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); } }
@Override public Tuple<String, Iterable<Table>> listTables(String datasetId, Map<Option, ?> options) { try { TableList tableList = bigquery.tables() .list(this.options.projectId(), datasetId) .setMaxResults(MAX_RESULTS.getLong(options)) .setPageToken(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); } }