rdblue commented on code in PR #18248:
URL: https://github.com/apache/iceberg/pull/18248#discussion_r4108378738
##########
core/src/test/java/org/apache/iceberg/TestV4ManifestReader.java:
##########
@@ -370,146 +467,178 @@ public void
inheritanceUncommittedOnlyInheritsSnapshotId(FileFormat format) thro
.metricsConfig(METRICS_CONFIG);
List<TrackedFile> actual = read(builder);
+ List<TrackedFile> expected =
+ List.of(
+ unpartitionedDataFile(
+ new TrackingStruct(EntryStatus.ADDED, 1234567L, null, null,
null, null, null, null),
+ "s3://bucket/table/file-b.parquet"),
+ unpartitionedDataFile( // inherits only snapshot ID
+ new TrackingStruct(EntryStatus.ADDED, 34L, null, null, null,
null, null, null),
+ "s3://bucket/table/file-a.parquet"));
+
assertThat(actual)
- .extracting(file -> file.tracking().snapshotId())
- .containsExactly(1234567L, SNAPSHOT_ID);
- assertThat(actual)
- .as("Uncommitted files do not inherit data sequence number")
- .extracting(file -> file.tracking().dataSequenceNumber())
- .containsOnlyNulls();
- assertThat(actual)
- .as("Uncommitted files do not inherit file sequence number")
- .extracting(file -> file.tracking().fileSequenceNumber())
- .containsOnlyNulls();
+ .usingComparatorForType(FILE_AND_TRACKING_COMPARATOR,
TrackedFile.class)
+ .isEqualTo(expected);
}
@ParameterizedTest
@FieldSource("MANIFEST_FORMATS")
public void inheritanceSnapshotId(FileFormat format) throws IOException {
- Tracking trackingWithSnapshotId =
- new TrackingStruct(EntryStatus.ADDED, 1234567L, null, null, null,
null, null, null);
TrackedFile withSnapshotId =
- unpartitionedDataFile(trackingWithSnapshotId,
"s3://bucket/table/file-b.parquet");
- Tracking trackingWithoutSnapshotId =
- new TrackingStruct(EntryStatus.ADDED, null, null, null, null, null,
null, null);
+ unpartitionedDataFile(
+ new TrackingStruct(EntryStatus.ADDED, 1234567L, 5L, 5L, null,
5_000L, null, null),
+ "s3://bucket/table/file-b.parquet");
TrackedFile withoutSnapshotId =
- unpartitionedDataFile(trackingWithoutSnapshotId,
"s3://bucket/table/file-a.parquet");
+ unpartitionedDataFile(
+ new TrackingStruct(EntryStatus.ADDED, null, 5L, 5L, null, 5_100L,
null, null),
+ "s3://bucket/table/file-a.parquet");
ManifestFile manifest =
writeManifest(
format, UNPARTITIONED_TYPE, ImmutableList.of(withSnapshotId,
withoutSnapshotId));
+ when(manifest.firstRowId()).thenReturn(10_000L);
+ when(manifest.snapshotId()).thenReturn(34L);
+
V4ManifestReader.Builder builder =
V4ManifestReader.builder(manifest, IO, TABLE_SCHEMA,
ID_PARTITIONING_SPECS)
.metricsConfig(METRICS_CONFIG);
List<TrackedFile> actual = read(builder);
+ List<TrackedFile> expected =
+ List.of(
+ unpartitionedDataFile(
+ new TrackingStruct(EntryStatus.ADDED, 1234567L, 5L, 5L, null,
5_000L, null, null),
+ "s3://bucket/table/file-b.parquet"),
+ unpartitionedDataFile( // inherits only snapshot ID
+ new TrackingStruct(EntryStatus.ADDED, 34L, 5L, 5L, null,
5_100L, null, null),
+ "s3://bucket/table/file-a.parquet"));
+
assertThat(actual)
- .extracting(file -> file.tracking().snapshotId())
- .containsExactly(1234567L, SNAPSHOT_ID);
+ .usingComparatorForType(FILE_AND_TRACKING_COMPARATOR,
TrackedFile.class)
+ .isEqualTo(expected);
}
@ParameterizedTest
@FieldSource("MANIFEST_FORMATS")
public void inheritanceDVSnapshotIdNotInherited(FileFormat format) throws
IOException {
- Tracking trackingWithDVSnapshotId =
- new TrackingStruct(EntryStatus.ADDED, SNAPSHOT_ID, null, null,
1234567L, null, null, null);
TrackedFile withDVSnapshotId =
- unpartitionedDataFile(trackingWithDVSnapshotId,
"s3://bucket/table/file-b.parquet");
- Tracking trackingWithoutDVSnapshotId =
- new TrackingStruct(EntryStatus.ADDED, SNAPSHOT_ID, null, null, null,
null, null, null);
+ unpartitionedDataFile(
+ new TrackingStruct(
+ EntryStatus.ADDED, SNAPSHOT_ID, 5L, 5L, 1234567L, 5_000L,
null, null),
+ "s3://bucket/table/file-b.parquet");
TrackedFile withoutDVSnapshotId =
- unpartitionedDataFile(trackingWithoutDVSnapshotId,
"s3://bucket/table/file-a.parquet");
+ unpartitionedDataFile(
+ new TrackingStruct(EntryStatus.ADDED, SNAPSHOT_ID, 5L, 5L, null,
5_100L, null, null),
+ "s3://bucket/table/file-a.parquet");
ManifestFile manifest =
writeManifest(
format, UNPARTITIONED_TYPE, ImmutableList.of(withDVSnapshotId,
withoutDVSnapshotId));
+ when(manifest.firstRowId()).thenReturn(10_000L);
+ when(manifest.snapshotId()).thenReturn(34L);
+
V4ManifestReader.Builder builder =
V4ManifestReader.builder(manifest, IO, TABLE_SCHEMA,
ID_PARTITIONING_SPECS)
.metricsConfig(METRICS_CONFIG);
List<TrackedFile> actual = read(builder);
+ List<TrackedFile> expected =
+ List.of(
+ unpartitionedDataFile(
+ new TrackingStruct(
+ EntryStatus.ADDED, SNAPSHOT_ID, 5L, 5L, 1234567L, 5_000L,
null, null),
+ "s3://bucket/table/file-b.parquet"),
+ unpartitionedDataFile( // inherits only snapshot ID
Review Comment:
Fixed.
--
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]