anoopj commented on code in PR #17932:
URL: https://github.com/apache/iceberg/pull/17932#discussion_r3926710524
##########
core/src/test/java/org/apache/iceberg/TestTrackedFileAdapters.java:
##########
@@ -346,6 +366,213 @@ void dvDeleteFileAdapterRejectsNullDeletionVector() {
.hasMessage("Cannot create DV delete file: no deletion vector");
}
+ @ParameterizedTest
+ @EnumSource(
+ value = FileContent.class,
+ names = {"DATA_MANIFEST", "DELETE_MANIFEST"})
+ void manifestFileAdapterDelegation(FileContent contentType) {
+ ByteBuffer keyMetadata = ByteBuffer.wrap(new byte[] {7, 8, 9});
+ TrackedFile file =
+ new TrackedFileStruct(
+ MANIFEST_TRACKING,
+ contentType,
+ FORMAT_VERSION_V4,
+ MANIFEST_FILE_LOCATION,
+ FileFormat.PARQUET,
+ 0L,
+ MANIFEST_FILE_SIZE,
+ null,
+ null,
+ null,
+ null,
+ null,
+ MANIFEST_INFO,
+ keyMetadata,
+ null,
+ null);
+
+ ManifestFile manifest = TrackedFileAdapters.asManifestFile(file);
+
+ ManifestContent expectedContent =
+ contentType == FileContent.DATA_MANIFEST ? ManifestContent.DATA :
ManifestContent.DELETES;
+ assertThat(manifest.path()).isEqualTo(MANIFEST_FILE_LOCATION);
+ assertThat(manifest.length()).isEqualTo(MANIFEST_FILE_SIZE);
+ assertThat(manifest.content()).isEqualTo(expectedContent);
+ assertThat(manifest.sequenceNumber()).isEqualTo(DATA_SEQUENCE_NUMBER);
+
assertThat(manifest.minSequenceNumber()).isEqualTo(MANIFEST_INFO.minSequenceNumber());
+ assertThat(manifest.snapshotId()).isEqualTo(SNAPSHOT_ID);
+
assertThat(manifest.addedFilesCount()).isEqualTo(MANIFEST_INFO.addedFilesCount());
+
assertThat(manifest.addedRowsCount()).isEqualTo(MANIFEST_INFO.addedRowsCount());
+
assertThat(manifest.existingFilesCount()).isEqualTo(MANIFEST_INFO.existingFilesCount());
+
assertThat(manifest.existingRowsCount()).isEqualTo(MANIFEST_INFO.existingRowsCount());
+
assertThat(manifest.deletedFilesCount()).isEqualTo(MANIFEST_INFO.deletedFilesCount());
+
assertThat(manifest.deletedRowsCount()).isEqualTo(MANIFEST_INFO.deletedRowsCount());
+ assertThat(manifest.firstRowId()).isEqualTo(FIRST_ROW_ID);
+ assertThat(manifest.keyMetadata()).isEqualTo(keyMetadata);
+
assertThat(manifest.deletionVector()).isEqualTo(ByteBuffer.wrap(MANIFEST_DV));
+ assertThat(manifest.partitions()).isNull();
+ }
+
+ @Test
+ void manifestFileAdapterPartitionSpecIdUnsupported() {
+ TrackedFile file =
+ new TrackedFileStruct(
+ MANIFEST_TRACKING,
+ FileContent.DATA_MANIFEST,
+ FORMAT_VERSION_V4,
+ MANIFEST_FILE_LOCATION,
+ FileFormat.PARQUET,
+ 0L,
+ MANIFEST_FILE_SIZE,
+ null,
+ null,
+ null,
+ null,
+ null,
+ MANIFEST_INFO,
+ null,
+ null,
+ null);
+
+ ManifestFile manifest = TrackedFileAdapters.asManifestFile(file);
+
+ assertThatThrownBy(manifest::partitionSpecId)
+ .isInstanceOf(UnsupportedOperationException.class)
+ .hasMessage("v4 manifests are not bound to a single partition spec");
+ }
+
+ @Test
+ void manifestFileAdapterCopy() {
+ ByteBuffer keyMetadata = ByteBuffer.wrap(new byte[] {7, 8, 9});
+ TrackedFile file =
+ new TrackedFileStruct(
+ MANIFEST_TRACKING,
+ FileContent.DATA_MANIFEST,
+ FORMAT_VERSION_V4,
+ MANIFEST_FILE_LOCATION,
+ FileFormat.PARQUET,
+ 0L,
+ MANIFEST_FILE_SIZE,
+ null,
+ null,
+ null,
+ null,
+ null,
+ MANIFEST_INFO,
+ keyMetadata,
+ null,
+ null);
+
+ ManifestFile original = TrackedFileAdapters.asManifestFile(file);
+ ManifestFile copy = original.copy();
+
+ assertThat(copy.path()).isEqualTo(original.path());
+ assertThat(copy.length()).isEqualTo(original.length());
+ assertThat(copy.content()).isEqualTo(original.content());
+ assertThat(copy.sequenceNumber()).isEqualTo(original.sequenceNumber());
+
assertThat(copy.minSequenceNumber()).isEqualTo(original.minSequenceNumber());
+ assertThat(copy.snapshotId()).isEqualTo(original.snapshotId());
+ assertThat(copy.addedFilesCount()).isEqualTo(original.addedFilesCount());
+ assertThat(copy.addedRowsCount()).isEqualTo(original.addedRowsCount());
+
assertThat(copy.existingFilesCount()).isEqualTo(original.existingFilesCount());
+
assertThat(copy.existingRowsCount()).isEqualTo(original.existingRowsCount());
+
assertThat(copy.deletedFilesCount()).isEqualTo(original.deletedFilesCount());
+ assertThat(copy.deletedRowsCount()).isEqualTo(original.deletedRowsCount());
+ assertThat(copy.firstRowId()).isEqualTo(original.firstRowId());
+ assertThat(copy.partitions()).isNull();
+ assertThat(copy.keyMetadata()).isEqualTo(original.keyMetadata());
+
assertThat(copy.keyMetadata().array()).isNotSameAs(original.keyMetadata().array());
+ assertThat(copy.deletionVector()).isEqualTo(original.deletionVector());
+
assertThat(copy.deletionVector().array()).isNotSameAs(original.deletionVector().array());
Review Comment:
Thank you. Converting it to mocks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]