use of com.amazonaws.services.glue.model.GetTablesRequest in project presto by prestodb.
the class GlueHiveMetastore method getAllTables.
@Override
public Optional<List<String>> getAllTables(MetastoreContext metastoreContext, String databaseName) {
try {
List<String> tableNames = new ArrayList<>();
GetTablesRequest request = new GetTablesRequest().withCatalogId(catalogId).withDatabaseName(databaseName);
do {
GetTablesResult result = stats.getGetTables().record(() -> glueClient.getTables(request));
request.setNextToken(result.getNextToken());
result.getTableList().forEach(table -> tableNames.add(table.getName()));
} while (request.getNextToken() != 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);
}
}
use of com.amazonaws.services.glue.model.GetTablesRequest in project presto by prestodb.
the class GlueHiveMetastore method getAllViews.
@Override
public Optional<List<String>> getAllViews(MetastoreContext metastoreContext, String databaseName) {
try {
List<String> views = new ArrayList<>();
GetTablesRequest request = new GetTablesRequest().withCatalogId(catalogId).withDatabaseName(databaseName);
do {
GetTablesResult result = stats.getGetTables().record(() -> glueClient.getTables(request));
request.setNextToken(result.getNextToken());
result.getTableList().stream().filter(table -> VIRTUAL_VIEW.name().equals(table.getTableType())).forEach(table -> views.add(table.getName()));
} while (request.getNextToken() != 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);
}
}
use of com.amazonaws.services.glue.model.GetTablesRequest in project alluxio by Alluxio.
the class GlueDatabase method getTableNames.
@Override
public List<String> getTableNames() throws IOException {
try {
String nextToken = null;
List<String> tableNames = new ArrayList<>();
do {
GetTablesRequest tablesRequest = new GetTablesRequest().withCatalogId(mGlueConfiguration.get(Property.CATALOG_ID)).withDatabaseName(mGlueDbName).withNextToken(nextToken);
GetTablesResult tablesResult = mGlueClient.getTables(tablesRequest);
tablesResult.getTableList().forEach(table -> tableNames.add(table.getName()));
nextToken = tablesResult.getNextToken();
} while (nextToken != null);
return tableNames;
} catch (EntityNotFoundException e) {
throw new IOException("Failed to get glue tables: " + e.getMessage() + " in Database: " + mGlueDbName + "; with Catalog ID: " + mGlueConfiguration.get(Property.CATALOG_ID) + ".", e);
}
}
Aggregations