Search in sources :

Example 1 with TableNameInfo

use of io.cdap.cdap.proto.TableNameInfo in project cdap by caskdata.

the class BaseHiveExploreService method getTables.

@Override
public List<TableNameInfo> getTables(final String namespace) throws ExploreException {
    startAndWait();
    // TODO check if the database user is allowed to access if security is enabled
    try {
        String database = getHiveDatabase(namespace);
        ImmutableList.Builder<TableNameInfo> builder = ImmutableList.builder();
        List<String> tables = getMetaStoreClient().getAllTables(database);
        for (String table : tables) {
            builder.add(new TableNameInfo(database, table));
        }
        return builder.build();
    } catch (TException e) {
        throw new ExploreException("Error connecting to Hive metastore", e);
    }
}
Also used : TException(org.apache.thrift.TException) ImmutableList(com.google.common.collect.ImmutableList) TableNameInfo(io.cdap.cdap.proto.TableNameInfo) ExploreException(io.cdap.cdap.explore.service.ExploreException)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ExploreException (io.cdap.cdap.explore.service.ExploreException)1 TableNameInfo (io.cdap.cdap.proto.TableNameInfo)1 TException (org.apache.thrift.TException)1