amogh-jahagirdar commented on code in PR #17035:
URL: https://github.com/apache/iceberg/pull/17035#discussion_r3509834370
##########
core/src/test/java/org/apache/iceberg/TestTrackedFileStruct.java:
##########
@@ -132,19 +111,105 @@ void testFieldAccess() {
}
@Test
- void testReaderSideFields() {
+ void testSetByPosition() {
+ Tracking tracking =
+ new TrackingStruct(EntryStatus.ADDED, 42L, null, null, null, null,
null, null, null, -1L);
+ PartitionData partition = newPartition(7, "music");
+
TrackedFileStruct file = new TrackedFileStruct();
+ file.set(0, tracking);
+ file.set(1, FileContent.DATA.id());
+ file.set(2, FORMAT_VERSION_V4);
+ file.set(3, "s3://bucket/data/00000-0-file.parquet");
+ file.set(4, "parquet");
+ file.set(5, 50L);
+ file.set(6, 512L);
+ file.set(7, 1);
+ file.set(8, partition);
+ file.set(9, CONTENT_STATS);
+ file.set(10, 5);
+ file.set(11, DELETION_VECTOR);
+ file.set(12, MANIFEST_INFO);
+ file.set(13, ByteBuffer.wrap(new byte[] {1, 2, 3}));
+ file.set(14, ImmutableList.of(100L, 200L));
+ file.set(15, ImmutableList.of(1, 2, 3));
+
+ assertThat(file.tracking()).isSameAs(tracking);
+ assertThat(file.contentType()).isEqualTo(FileContent.DATA);
+ assertThat(file.formatVersion()).isEqualTo(FORMAT_VERSION_V4);
+
assertThat(file.location()).isEqualTo("s3://bucket/data/00000-0-file.parquet");
+ assertThat(file.fileFormat()).isEqualTo(FileFormat.PARQUET);
+ assertThat(file.recordCount()).isEqualTo(50L);
+ assertThat(file.fileSizeInBytes()).isEqualTo(512L);
+ assertThat(file.specId()).isEqualTo(1);
+ assertThat(file.partition()).isSameAs(partition);
+ assertThat(file.contentStats()).isSameAs(CONTENT_STATS);
+ assertThat(file.sortOrderId()).isEqualTo(5);
+ assertThat(file.deletionVector()).isSameAs(DELETION_VECTOR);
+ assertThat(file.manifestInfo()).isSameAs(MANIFEST_INFO);
+ assertThat(file.keyMetadata()).isEqualTo(ByteBuffer.wrap(new byte[] {1, 2,
3}));
+ assertThat(file.splitOffsets()).containsExactly(100L, 200L);
+ assertThat(file.equalityIds()).containsExactly(1, 2, 3);
+ }
+
+ @Test
+ void testGetByPosition() {
+ Tracking tracking =
+ new TrackingStruct(EntryStatus.ADDED, 42L, null, null, null, null,
null, null, null, -1L);
+ PartitionData partition = newPartition(7, "music");
+ TrackedFileStruct file =
+ new TrackedFileStruct(
+ tracking,
+ FileContent.DATA,
+ FORMAT_VERSION_V4,
+ "s3://bucket/data/00000-0-file.parquet",
+ FileFormat.PARQUET,
+ partition,
+ 50L,
+ 512L,
+ 1,
+ CONTENT_STATS,
+ 5,
+ DELETION_VECTOR,
+ MANIFEST_INFO,
+ ByteBuffer.wrap(new byte[] {1, 2, 3}),
+ ImmutableList.of(100L, 200L),
+ ImmutableList.of(1, 2, 3));
+
+ assertThat(file.get(0, Tracking.class)).isSameAs(tracking);
+ assertThat(file.get(1, Integer.class)).isEqualTo(FileContent.DATA.id());
+ assertThat(file.get(2, Integer.class)).isEqualTo(FORMAT_VERSION_V4);
+ assertThat(file.get(3,
String.class)).isEqualTo("s3://bucket/data/00000-0-file.parquet");
+ assertThat(file.get(4,
String.class)).isEqualTo(FileFormat.PARQUET.toString());
+ assertThat(file.get(5, Long.class)).isEqualTo(50L);
+ assertThat(file.get(6, Long.class)).isEqualTo(512L);
+ assertThat(file.get(7, Integer.class)).isEqualTo(1);
+ assertThat(file.get(8, PartitionData.class)).isSameAs(partition);
+ assertThat(file.get(9, ContentStats.class)).isSameAs(CONTENT_STATS);
+ assertThat(file.get(10, Integer.class)).isEqualTo(5);
+ assertThat(file.get(11, DeletionVector.class)).isSameAs(DELETION_VECTOR);
+ assertThat(file.get(12, ManifestInfo.class)).isSameAs(MANIFEST_INFO);
+ assertThat(file.get(13, ByteBuffer.class)).isEqualTo(ByteBuffer.wrap(new
byte[] {1, 2, 3}));
+ assertThat(file.get(14, List.class)).containsExactly(100L, 200L);
+ assertThat(file.get(15, List.class)).containsExactly(1, 2, 3);
+ }
+
+ @Test
+ void testReaderSideFields() {
+ // manifest_location and manifest_pos are populated by readers, not
written to manifests.
+ // manifest_pos is ROW_POSITION, appended after the tracking schema fields
(position 8).
Review Comment:
AI comment but I think it's useful context, it's not super obvious why we
have this separate test without this comment.
--
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]