wypoon commented on a change in pull request #3722:
URL: https://github.com/apache/iceberg/pull/3722#discussion_r770192289
##########
File path:
spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestSelect.java
##########
@@ -120,4 +124,82 @@ public void testMetadataTables() {
ImmutableList.of(row(ANY, ANY, null, "append", ANY, ANY)),
sql("SELECT * FROM %s.snapshots", tableName));
}
+
+ @Test
+ public void testSnapshotInTableName() {
+ Assume.assumeFalse(
+ "Spark session catalog does not support extended table names",
+ "spark_catalog".equals(catalogName));
+
+ // get the snapshot ID of the last write and get the current row set as
expected
+ long snapshotId =
validationCatalog.loadTable(tableIdent).currentSnapshot().snapshotId();
+ List<Object[]> expected = sql("SELECT * FROM %s", tableName);
+
+ // create a second snapshot
+ sql("INSERT INTO %s VALUES (4, 'd', 4.0), (5, 'e', 5.0)", tableName);
+
+ String prefix = "snapshot_id_";
+ // read the table at the snapshot
+ List<Object[]> actual = sql("SELECT * FROM %s.%s", tableName, prefix +
snapshotId);
+ assertEquals("Snapshot at specific ID, prefix " + prefix, expected,
actual);
+
+ // read the table using DataFrameReader option
+ Dataset<Row> df = spark.read()
+ .format("iceberg")
+ .option(SparkReadOptions.SNAPSHOT_ID, snapshotId)
+ .load(tableName);
+ List<Object[]> fromDF = rowsToJava(df.collectAsList());
+ assertEquals("Snapshot at specific ID " + snapshotId, expected, fromDF);
+ }
+
+ @Test
+ public void testTimestampInTableName() {
+ Assume.assumeFalse(
+ "Spark session catalog does not support extended table names",
+ "spark_catalog".equals(catalogName));
+
+ // get a timestamp just after the last write and get the current row set
as expected
+ long timestamp =
validationCatalog.loadTable(tableIdent).currentSnapshot().timestampMillis() + 2;
Review comment:
I added a `waitUntilAfter`.
--
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]