Example usage for com.amazonaws.services.glue.model GetTablesResult getTableList

List of usage examples for com.amazonaws.services.glue.model GetTablesResult getTableList

Introduction

In this page you can find the example usage for com.amazonaws.services.glue.model GetTablesResult getTableList.

Prototype


public java.util.List<Table> getTableList() 

Source Link

Document

A list of the requested Table objects.

Usage

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);
    }
}