singhpk234 commented on code in PR #5063:
URL: https://github.com/apache/iceberg/pull/5063#discussion_r924039877


##########
spark/v3.2/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestMetadataTables.java:
##########
@@ -319,6 +320,52 @@ public void testAllFilesPartitioned() throws Exception {
     TestHelpers.assertEqualsSafe(filesTableSchema.asStruct(), expectedFiles, 
actualFiles);
   }
 
+  @Test
+  public void testMetadataLogMetatable() throws Exception {
+    // Create table and insert data
+    sql("CREATE TABLE %s (id bigint, data string) " +
+        "USING iceberg " +
+        "PARTITIONED BY (data)", tableName);
+
+    List<SimpleRecord> recordsA = Lists.newArrayList(
+        new SimpleRecord(1, "a"),
+        new SimpleRecord(2, "a")
+    );
+    spark.createDataset(recordsA, Encoders.bean(SimpleRecord.class))
+        .writeTo(tableName)
+        .append();
+
+    List<SimpleRecord> recordsB = Lists.newArrayList(
+        new SimpleRecord(1, "b"),
+        new SimpleRecord(2, "b")
+    );
+    spark.createDataset(recordsB, Encoders.bean(SimpleRecord.class))
+        .writeTo(tableName)
+        .append();
+
+    Table table = Spark3Util.loadIcebergTable(spark, tableName);
+    Long currentSnapshotId = table.currentSnapshot().snapshotId();
+
+    // Check metadataLog table
+    List<Object[]> metadataLogs = sql("SELECT * FROM %s.metadata_log", 
tableName);
+    Assert.assertEquals("metadataLog table should return 3 rows", 3, 
metadataLogs.size());
+
+    // test filtering
+    List<Object[]> metadataLogWithFilters =
+        sql("SELECT * FROM %s.metadata_log WHERE latest_snapshot_id = %s", 
tableName, currentSnapshotId);
+    Assert.assertEquals("metadataLog table should return 1 row", 1, 
metadataLogWithFilters.size());
+    Assert.assertEquals("timestampMillis should match currentSnapshot",
+        table.currentSnapshot().timestampMillis() * 1000, 
metadataLogWithFilters.get(0)[0]);

Review Comment:
   you are correct, missed this part i initially wanted to have timestamp in 
microseconds so that i can show the timestamp like `2022-06-16 16:39:27.128`, 
we do in snapshot table, but later decided to leave this at timestamp in 
milliseconds. Corrected to supply timestamp in millis.



-- 
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]

Reply via email to