/** * {@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); } } }
/** * {@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); } } }
/** * {@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); } }
.auditInfo(AuditInfo.builder().createdBy(tableAuditInfo.getCreatedBy()) .createdDate(fromEpochMilliToDate(partitionMap.get(partitionName).dataTimestampMillis())) .lastModifiedDate(fromEpochMilliToDate(partitionMap.get(partitionName).dataTimestampMillis()))
.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()
.auditInfo(AuditInfo.builder().createdBy(tableAuditInfo.getCreatedBy()) .createdDate(fromEpochMilliToDate(partitionMap.get(partitionName).dataTimestampMillis())) .lastModifiedDate(fromEpochMilliToDate(partitionMap.get(partitionName).dataTimestampMillis()))
@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()
/** * 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(); }
/** * Converts to PartitionDto. * * @param partition connector partition * @return Metacat partition Info */ @Override public PartitionInfo toPartitionInfo( final TableInfo tableInfo, 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(); }
/** * Converts to PartitionDto. * * @param partition connector partition * @return Metacat partition Info */ @Override public PartitionInfo toPartitionInfo( final TableInfo tableInfo, 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(); }