Search in sources :

Example 11 with HiveMetastoreClientPool

use of org.apache.gobblin.hive.HiveMetastoreClientPool in project incubator-gobblin by apache.

the class HiveMaterializerSource method getHiveDataset.

private HiveDataset getHiveDataset(String tableString, FileSystem fs, State state) throws IOException {
    try {
        HiveMetastoreClientPool pool = HiveMetastoreClientPool.get(state.getProperties(), Optional.fromNullable(state.getProp(HIVE_METASTORE_URI_KEY)));
        List<String> tokens = Splitter.on(".").splitToList(tableString);
        DbAndTable sourceDbAndTable = new DbAndTable(tokens.get(0), tokens.get(1));
        try (AutoReturnableObject<IMetaStoreClient> client = pool.getClient()) {
            Table sourceTable = new Table(client.get().getTable(sourceDbAndTable.getDb(), sourceDbAndTable.getTable()));
            return new HiveDataset(fs, pool, sourceTable, ConfigUtils.propertiesToConfig(state.getProperties()));
        }
    } catch (TException exc) {
        throw new RuntimeException(exc);
    }
}
Also used : TException(org.apache.thrift.TException) Table(org.apache.hadoop.hive.ql.metadata.Table) HiveDataset(org.apache.gobblin.data.management.copy.hive.HiveDataset) IMetaStoreClient(org.apache.hadoop.hive.metastore.IMetaStoreClient) HiveMetastoreClientPool(org.apache.gobblin.hive.HiveMetastoreClientPool)

Aggregations

HiveMetastoreClientPool (org.apache.gobblin.hive.HiveMetastoreClientPool)11 Properties (java.util.Properties)6 Configuration (org.apache.hadoop.conf.Configuration)6 Test (org.testng.annotations.Test)6 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)5 Table (org.apache.hadoop.hive.metastore.api.Table)4 TException (org.apache.thrift.TException)4 IOException (java.io.IOException)3 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)3 DataConversionException (org.apache.gobblin.converter.DataConversionException)2 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 Partition (org.apache.hadoop.hive.ql.metadata.Partition)2 List (java.util.List)1 HiveDataset (org.apache.gobblin.data.management.copy.hive.HiveDataset)1 Path (org.apache.hadoop.fs.Path)1 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)1 Table (org.apache.hadoop.hive.ql.metadata.Table)1