List of usage examples for com.amazonaws.services.glue.model GetTablesResult getTableList
public java.util.List<Table> getTableList()
A list of the requested Table
objects.
From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java
License:Apache License
@Override public Optional<List<String>> getAllTables(String databaseName) { try {/*from www. j a va2s . c om*/ List<String> tableNames = new ArrayList<>(); String nextToken = null; do { GetTablesResult result = glueClient .getTables(new GetTablesRequest().withDatabaseName(databaseName).withNextToken(nextToken)); result.getTableList().forEach(table -> tableNames.add(table.getName())); nextToken = result.getNextToken(); } while (nextToken != null); return Optional.of(tableNames); } catch (EntityNotFoundException e) { // database does not exist return Optional.empty(); } catch (AmazonServiceException e) { throw new PrestoException(HIVE_METASTORE_ERROR, e); } }
From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java
License:Apache License
@Override public Optional<List<String>> getAllViews(String databaseName) { try {/*from w w w .j av a2 s. c o m*/ List<String> views = new ArrayList<>(); String nextToken = null; do { GetTablesResult result = glueClient .getTables(new GetTablesRequest().withDatabaseName(databaseName).withNextToken(nextToken)); result.getTableList().stream().filter(table -> VIRTUAL_VIEW.name().equals(table.getTableType())) .forEach(table -> views.add(table.getName())); nextToken = result.getNextToken(); } while (nextToken != null); return Optional.of(views); } catch (EntityNotFoundException e) { // database does not exist return Optional.empty(); } catch (AmazonServiceException e) { throw new PrestoException(HIVE_METASTORE_ERROR, e); } }