/** * Creates audit info from s3 table info. * @param table table info * @return audit info */ public AuditInfo toAuditInfo(final Table table) { final AuditInfo result = AuditInfo.builder().createdDate(table.getCreatedDate()) .lastModifiedDate(table.getLastUpdatedDate()).build(); final Location location = table.getLocation(); if (location != null) { final Info info = location.getInfo(); if (info != null) { result.setCreatedBy(info.getOwner()); result.setLastModifiedBy(info.getOwner()); } } return result; }
@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(); }
/** * Returns a partition info. * @param tableName table name * @param table s3 table * @param partition partition * @return partition info */ PartitionInfo toPartitionInfo(final QualifiedName tableName, final Table table, final Partition partition) { final StorageInfo storageInfo = toStorageInfo(table); storageInfo.setUri(partition.getUri()); final AuditInfo auditInfo = AuditInfo.builder().createdDate(partition.getCreatedDate()) .lastModifiedDate(partition.getLastUpdatedDate()) .build(); final AuditInfo tableAuditInfo = toAuditInfo(table); 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(); }