use of org.apache.gobblin.hive.HivePartition in project incubator-gobblin by apache.
the class HiveMetaStoreUtils method getPartition.
/**
* Convert a {@link HivePartition} into a {@link Partition}.
*/
public static Partition getPartition(HivePartition hivePartition) {
State props = hivePartition.getProps();
Partition partition = new Partition();
partition.setDbName(hivePartition.getDbName());
partition.setTableName(hivePartition.getTableName());
partition.setValues(hivePartition.getValues());
partition.setParameters(getParameters(props));
if (hivePartition.getCreateTime().isPresent()) {
partition.setCreateTime(Ints.checkedCast(hivePartition.getCreateTime().get()));
} else if (props.contains(HiveConstants.CREATE_TIME)) {
partition.setCreateTime(props.getPropAsInt(HiveConstants.CREATE_TIME));
}
if (props.contains(HiveConstants.LAST_ACCESS_TIME)) {
partition.setLastAccessTime(props.getPropAsInt(HiveConstants.LAST_ACCESS_TIME));
}
partition.setSd(getStorageDescriptor(hivePartition));
return partition;
}
use of org.apache.gobblin.hive.HivePartition in project incubator-gobblin by apache.
the class HiveMetaStoreBasedRegister method registerPath.
@Override
protected void registerPath(HiveSpec spec) throws IOException {
try (Timer.Context context = this.metricContext.timer(PATH_REGISTER_TIMER).time();
AutoReturnableObject<IMetaStoreClient> client = this.clientPool.getClient()) {
Table table = HiveMetaStoreUtils.getTable(spec.getTable());
createDbIfNotExists(client.get(), table.getDbName());
createOrAlterTable(client.get(), table, spec);
Optional<HivePartition> partition = spec.getPartition();
if (partition.isPresent()) {
addOrAlterPartition(client.get(), table, HiveMetaStoreUtils.getPartition(partition.get()), spec);
}
HiveMetaStoreEventHelper.submitSuccessfulPathRegistration(eventSubmitter, spec);
} catch (TException e) {
HiveMetaStoreEventHelper.submitFailedPathRegistration(eventSubmitter, spec, e);
throw new IOException(e);
}
}
use of org.apache.gobblin.hive.HivePartition in project incubator-gobblin by apache.
the class HiveMetaStoreUtils method getHivePartition.
/**
* Convert a {@link Partition} into a {@link HivePartition}.
*/
public static HivePartition getHivePartition(Partition partition) {
State partitionProps = getPartitionProps(partition);
State storageProps = getStorageProps(partition.getSd());
State serDeProps = getSerDeProps(partition.getSd().getSerdeInfo());
HivePartition hivePartition = new HivePartition.Builder().withDbName(partition.getDbName()).withTableName(partition.getTableName()).withPartitionValues(partition.getValues()).withProps(partitionProps).withStorageProps(storageProps).withSerdeProps(serDeProps).build();
if (partition.getCreateTime() > 0) {
hivePartition.setCreateTime(partition.getCreateTime());
}
if (partition.getSd().getCols() != null) {
hivePartition.setColumns(getColumns(partition.getSd().getCols()));
}
if (partition.getSd().getBucketCols() != null) {
hivePartition.setBucketColumns(partition.getSd().getBucketCols());
}
return hivePartition;
}
Aggregations