/** * {@inheritDoc} */ @Override protected void setTableInfoDetails(final Connection connection, final TableInfo tableInfo) { final QualifiedName tableName = tableInfo.getName(); try ( final PreparedStatement statement = connection.prepareStatement(SQL_GET_AUDIT_INFO) ) { statement.setString(1, tableName.getDatabaseName()); statement.setString(2, tableName.getTableName()); try (final ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { final AuditInfo auditInfo = AuditInfo.builder().createdDate(resultSet.getDate(COL_CREATE_TIME)) .lastModifiedDate(resultSet.getDate(COL_UPDATE_TIME)).build(); tableInfo.setAudit(auditInfo); } } } catch (final Exception ignored) { log.info("Ignoring. Error getting the audit info for table {}", tableName); } } }
@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(); }
/** * 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; }
/** * 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; }
partitionInfo.setAudit(new AuditInfo()); final Partition existingPartition = existingPartitionHolder.getPartition(); partitionInfo.getSerde().setParameters(existingPartition.getParameters()); partitionInfo.getAudit().setCreatedDate( HiveConnectorInfoConverter.epochSecondsToDate(existingPartition.getCreateTime())); partitionInfo.getAudit().setLastModifiedDate( HiveConnectorInfoConverter.epochSecondsToDate(existingPartition.getLastAccessTime())); } else { .setCreatedDate(existingPartitionInfo.getAudit().getCreatedDate()); partitionInfo.getAudit() .setLastModifiedDate(existingPartitionInfo.getAudit().getLastModifiedDate());
.auditInfo(AuditInfo.builder().createdBy(tableAuditInfo.getCreatedBy()) .createdDate(fromEpochMilliToDate(partitionMap.get(partitionName).dataTimestampMillis())) .lastModifiedDate(fromEpochMilliToDate(partitionMap.get(partitionName).dataTimestampMillis()))
storageInfo.setOutputFormat(outputFormat); storageInfo.setSerializationLib(serializationLib); final AuditInfo auditInfo = new AuditInfo(); auditInfo.setCreatedDate(Date.from(Instant.ofEpochSecond(createdDate))); auditInfo.setLastModifiedDate(Date.from(Instant.ofEpochSecond(createdDate)));
final int createTime = (auditInfo != null && auditInfo.getCreatedDate() != null) ? dateToEpochSeconds(auditInfo.getCreatedDate()) : 0;
partitionInfo.setAudit(new AuditInfo()); final Partition existingPartition = existingPartitionHolder.getPartition(); partitionInfo.getSerde().setParameters(existingPartition.getParameters()); partitionInfo.getAudit().setCreatedDate( HiveConnectorInfoConverter.epochSecondsToDate(existingPartition.getCreateTime())); partitionInfo.getAudit().setLastModifiedDate( HiveConnectorInfoConverter.epochSecondsToDate(existingPartition.getLastAccessTime())); } else { .setCreatedDate(existingPartitionInfo.getAudit().getCreatedDate()); partitionInfo.getAudit() .setLastModifiedDate(existingPartitionInfo.getAudit().getLastModifiedDate());
.auditInfo(AuditInfo.builder().createdBy(tableAuditInfo.getCreatedBy()) .createdDate(fromEpochMilliToDate(partitionMap.get(partitionName).dataTimestampMillis())) .lastModifiedDate(fromEpochMilliToDate(partitionMap.get(partitionName).dataTimestampMillis()))
storageInfo.setOutputFormat(outputFormat); storageInfo.setSerializationLib(serializationLib); final AuditInfo auditInfo = new AuditInfo(); auditInfo.setCreatedDate(Date.from(Instant.ofEpochSecond(createdDate))); auditInfo.setLastModifiedDate(Date.from(Instant.ofEpochSecond(createdDate)));
final int createTime = (auditInfo != null && auditInfo.getCreatedDate() != null) ? dateToEpochSeconds(auditInfo.getCreatedDate()) : 0;
/** * {@inheritDoc} */ @Override protected void setTableInfoDetails(final Connection connection, final TableInfo tableInfo) { final QualifiedName tableName = tableInfo.getName(); try ( final PreparedStatement statement = connection.prepareStatement(SQL_GET_AUDIT_INFO) ) { statement.setString(1, tableName.getDatabaseName()); statement.setString(2, tableName.getTableName()); try (final ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { final AuditInfo auditInfo = AuditInfo.builder().createdDate(resultSet.getDate(COL_CREATE_TIME)) .lastModifiedDate(resultSet.getDate(COL_UPDATE_TIME)).build(); tableInfo.setAudit(auditInfo); } } } catch (final Exception ignored) { log.info("Ignoring. Error getting the audit info for table {}", tableName); } } }
/** * 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(); }
final int createTime = (notNull(auditInfo) && notNull(auditInfo.getCreatedDate())) ? dateToEpochSeconds(auditInfo.getCreatedDate()) : 0; final int lastAccessTime = (notNull(auditInfo) && notNull(auditInfo.getLastModifiedDate())) ? dateToEpochSeconds(auditInfo.getLastModifiedDate()) : 0;
/** * {@inheritDoc} */ @Override protected void setTableInfoDetails(final Connection connection, final TableInfo tableInfo) { final QualifiedName tableName = getSnowflakeName(tableInfo.getName()); try ( PreparedStatement statement = connection.prepareStatement(SQL_GET_AUDIT_INFO) ) { statement.setString(1, tableName.getDatabaseName()); statement.setString(2, tableName.getDatabaseName()); statement.setString(3, tableName.getTableName()); try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { final AuditInfo auditInfo = AuditInfo.builder().createdDate(resultSet.getDate(COL_CREATED)) .lastModifiedDate(resultSet.getDate(COL_LAST_ALTERED)).build(); tableInfo.setAudit(auditInfo); } } } catch (final Exception ignored) { log.info("Ignoring. Error getting the audit info for table {}", tableName); } }
final int createTime = (notNull(auditInfo) && notNull(auditInfo.getCreatedDate())) ? dateToEpochSeconds(auditInfo.getCreatedDate()) : 0; final int lastAccessTime = (notNull(auditInfo) && notNull(auditInfo.getLastModifiedDate())) ? dateToEpochSeconds(auditInfo.getLastModifiedDate()) : 0;
@Override public DatabaseInfo toDatabaseInfo(final QualifiedName catalogName, final Database database) { final AuditInfo auditInfo = AuditInfo.builder().createdDate(database.getCreatedDate()) .lastModifiedDate(database.getLastUpdatedDate()).build(); return DatabaseInfo.builder().name(QualifiedName.ofDatabase(catalogName.getCatalogName(), database.getName())) .auditInfo(auditInfo).build(); }
.map(field -> hiveToMetacatField(field, true)) .forEachOrdered(allFields::add); final AuditInfo auditInfo = AuditInfo.builder().createdDate(creationDate).build(); if (null != table.getTableType() && table.getTableType().equals(TableType.VIRTUAL_VIEW.name())) { return TableInfo.builder()
.map(field -> hiveToMetacatField(field, true)) .forEachOrdered(allFields::add); final AuditInfo auditInfo = AuditInfo.builder().createdDate(creationDate).build(); if (null != table.getTableType() && table.getTableType().equals(TableType.VIRTUAL_VIEW.name())) { return TableInfo.builder()