rdblue commented on a change in pull request #750: Add time-travel methods
(asOfTime,useSnapshot) in IcebergGenerics
URL: https://github.com/apache/incubator-iceberg/pull/750#discussion_r371379140
##########
File path: data/src/test/java/org/apache/iceberg/data/TestLocalScan.java
##########
@@ -215,28 +275,90 @@ public void testFullScan() {
Iterable<Record> results = IcebergGenerics.read(sharedTable).build();
Set<Record> expected = Sets.newHashSet();
- expected.addAll(file1Records);
- expected.addAll(file2Records);
- expected.addAll(file3Records);
+ expected.addAll(file1SecondSnapshotRecords);
+ expected.addAll(file2SecondSnapshotRecords);
+ expected.addAll(file3SecondSnapshotRecords);
+
+ Set<Record> records = Sets.newHashSet(results);
+ Assert.assertEquals("Should produce correct number of records",
+ expected.size(), records.size());
+ Assert.assertEquals("Random record set should match",
+ Sets.newHashSet(expected), records);
+ Assert.assertNotNull(records.stream().findFirst().get().getField("id"));
+ Assert.assertNotNull(records.stream().findFirst().get().getField("data"));
+ }
+
+ @Test
+ public void testUnknownSnapshotId() {
+ exceptionRule.expect(IllegalArgumentException.class);
+ exceptionRule.expectMessage(startsWith("Cannot find snapshot with ID "));
+
+ Long minSnapshotId = sharedTable.history().stream().map(h ->
h.snapshotId()).min(Long::compareTo).get();
+
+ IcebergGenerics.read(sharedTable)
+ .useSnapshot(/* unknown snapshot id */ minSnapshotId - 1);
+ }
+
+ @Test
+ public void testAsOfTimeOlderThanFirstSnapshot() {
+ exceptionRule.expect(IllegalArgumentException.class);
+ exceptionRule.expectMessage(startsWith("Cannot find a snapshot older than
"));
+
+ IcebergGenerics.read(sharedTable)
+ .asOfTime(/* older than first snapshot */
sharedTable.history().get(0).timestampMillis() - 1);
+ }
+
+ @Test
+ public void testUseSnapshot() {
+ Iterable<Record> results = IcebergGenerics.read(sharedTable)
+ .useSnapshot(/* first snapshot */
sharedTable.history().get(0).snapshotId())
+ .build();
+
+ Set<Record> expected = Sets.newHashSet();
+ expected.addAll(file1FirstSnapshotRecords);
+ expected.addAll(file2FirstSnapshotRecords);
+ expected.addAll(file3FirstSnapshotRecords);
+
+ Set<Record> records = Sets.newHashSet(results);
+ Assert.assertEquals("Should produce correct number of records",
+ expected.size(), records.size());
+ Assert.assertEquals("Random record set should match",
Review comment:
Looks like a copy/paste error. This isn't a random record set. Can you
update this to "Record set should match"?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]