use of com.netflix.metacat.common.server.connectors.model.AuditInfo in project metacat by Netflix.
the class HiveConnectorInfoConverter method toPartitionInfo.
/**
* Converts to PartitionDto.
*
* @param partition connector partition
* @return Metacat partition Info
*/
@Override
public PartitionInfo toPartitionInfo(@Nonnull @NonNull final TableInfo tableInfo, @Nonnull @NonNull final Partition partition) {
final QualifiedName tableName = tableInfo.getName();
final QualifiedName partitionName = QualifiedName.ofPartition(tableName.getCatalogName(), tableName.getDatabaseName(), tableName.getTableName(), getNameFromPartVals(tableInfo, partition.getValues()));
final String owner = notNull(tableInfo.getSerde()) ? tableInfo.getSerde().getOwner() : "";
final AuditInfo auditInfo = AuditInfo.builder().createdDate(epochSecondsToDate(partition.getCreateTime())).lastModifiedDate(epochSecondsToDate(partition.getLastAccessTime())).build();
return PartitionInfo.builder().serde(toStorageInfo(partition.getSd(), owner)).name(partitionName).auditInfo(auditInfo).metadata(partition.getParameters()).build();
}
use of com.netflix.metacat.common.server.connectors.model.AuditInfo in project metacat by Netflix.
the class S3ConnectorInfoConverter method fromPartitionInfo.
/**
* Converts from partition info to s3 partition object.
* @param partitionInfo partition info
* @return s3 partition
*/
Partition fromPartitionInfo(final PartitionInfo partitionInfo) {
final Partition result = new Partition();
result.setName(partitionInfo.getName().getPartitionName());
result.setUri(partitionInfo.getSerde().getUri());
final AuditInfo auditInfo = partitionInfo.getAudit();
if (auditInfo != null) {
result.setCreatedDate(auditInfo.getCreatedDate());
result.setLastUpdatedDate(auditInfo.getLastModifiedDate());
}
return result;
}
use of com.netflix.metacat.common.server.connectors.model.AuditInfo in project metacat by Netflix.
the class S3ConnectorInfoConverter method toPartitionInfo.
@Override
public PartitionInfo toPartitionInfo(final TableInfo tableInfo, final Partition partition) {
final QualifiedName tableName = tableInfo.getName();
final StorageInfo storageInfo = tableInfo.getSerde();
storageInfo.setUri(partition.getUri());
final AuditInfo auditInfo = AuditInfo.builder().createdDate(partition.getCreatedDate()).lastModifiedDate(partition.getLastUpdatedDate()).build();
final AuditInfo tableAuditInfo = tableInfo.getAudit();
if (tableAuditInfo != null) {
auditInfo.setCreatedBy(tableAuditInfo.getCreatedBy());
auditInfo.setLastModifiedBy(tableAuditInfo.getLastModifiedBy());
}
return PartitionInfo.builder().name(QualifiedName.ofPartition(tableName.getCatalogName(), tableName.getDatabaseName(), tableName.getTableName(), partition.getName())).serde(storageInfo).auditInfo(auditInfo).build();
}
use of com.netflix.metacat.common.server.connectors.model.AuditInfo in project metacat by Netflix.
the class HiveConnectorInfoConverter method fromTableInfo.
/**
* Converts from TableDto to the connector table.
*
* @param tableInfo Metacat table Info
* @return connector table
*/
@Override
public Table fromTableInfo(@Nonnull @NonNull final TableInfo tableInfo) {
final QualifiedName name = tableInfo.getName();
final String tableName = (name != null) ? name.getTableName() : "";
final String databaseName = (name != null) ? name.getDatabaseName() : "";
final StorageInfo storageInfo = tableInfo.getSerde();
final String owner = (storageInfo != null && storageInfo.getOwner() != null) ? storageInfo.getOwner() : "";
final AuditInfo auditInfo = tableInfo.getAudit();
final int createTime = (auditInfo != null && auditInfo.getCreatedDate() != null) ? dateToEpochSeconds(auditInfo.getCreatedDate()) : 0;
final Map<String, String> params = (tableInfo.getMetadata() != null) ? tableInfo.getMetadata() : new HashMap<>();
final List<FieldInfo> fields = tableInfo.getFields();
List<FieldSchema> partitionFields = Collections.emptyList();
List<FieldSchema> nonPartitionFields = Collections.emptyList();
if (fields != null) {
nonPartitionFields = Lists.newArrayListWithCapacity(fields.size());
partitionFields = Lists.newArrayListWithCapacity(fields.size());
for (FieldInfo fieldInfo : fields) {
if (fieldInfo.isPartitionKey()) {
partitionFields.add(metacatToHiveField(fieldInfo));
} else {
nonPartitionFields.add(metacatToHiveField(fieldInfo));
}
}
}
final StorageDescriptor sd = fromStorageInfo(storageInfo, nonPartitionFields);
return new Table(tableName, databaseName, owner, createTime, 0, 0, sd, partitionFields, params, null, null, "EXTERNAL_TABLE");
}
Aggregations