RussellSpitzer commented on a change in pull request #3039:
URL: https://github.com/apache/iceberg/pull/3039#discussion_r765839809
##########
File path:
spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestStructuredStreamingRead3.java
##########
@@ -165,6 +166,155 @@ public void
testReadStreamOnIcebergTableWithMultipleSnapshots() throws Exception
Assertions.assertThat(actual).containsExactlyInAnyOrderElementsOf(Iterables.concat(expected));
}
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testReadingStreamFromTimestamp() throws Exception {
+ List<SimpleRecord> dataBeforeTimestamp = Lists.newArrayList(
+ new SimpleRecord(-2, "minustwo"),
+ new SimpleRecord(-1, "minusone"),
+ new SimpleRecord(0, "zero"));
+ appendData(dataBeforeTimestamp, tableIdentifier, "parquet");
+
+ table.refresh();
+ long streamStartTimestamp = table.currentSnapshot().timestampMillis() + 1;
+ waitUntilAfter(streamStartTimestamp);
+
+ List<List<SimpleRecord>> expected = TEST_DATA_MULTIPLE_SNAPSHOTS;
+ appendDataAsMultipleSnapshots(expected, tableIdentifier);
+
+ table.refresh();
+
+ Dataset<Row> df = spark.readStream()
+ .format("iceberg")
+ .option(SparkReadOptions.STREAM_FROM_TIMESTAMP,
Long.toString(streamStartTimestamp))
+ .load(tableIdentifier);
+ List<SimpleRecord> actual = processAvailable(df);
+
+
Assertions.assertThat(actual).containsExactlyInAnyOrderElementsOf(Iterables.concat(expected));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testReadingStreamAfterLatestTimestamp() throws Exception {
+ List<SimpleRecord> dataBeforeTimestamp = Lists.newArrayList(
+ new SimpleRecord(-2, "minustwo"),
+ new SimpleRecord(-1, "minusone"),
+ new SimpleRecord(0, "zero"));
+ appendData(dataBeforeTimestamp, tableIdentifier, "parquet");
+
+ table.refresh();
+ long streamStartTimestamp = table.currentSnapshot().timestampMillis() + 1;
+ waitUntilAfter(streamStartTimestamp);
+
+ Dataset<Row> df = spark.readStream()
+ .format("iceberg")
+ .option(SparkReadOptions.STREAM_FROM_TIMESTAMP,
Long.toString(streamStartTimestamp))
+ .load(tableIdentifier);
+ List<SimpleRecord> actual = processAvailable(df);
+ Assertions.assertThat(actual.isEmpty()).isTrue();
+ }
+
+ @SuppressWarnings("unchecked")
Review comment:
I'd rather we didn't surpress warnings here, I assume this is because we
are throws Exception instead of the actual type?
--
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]