syun64 commented on code in PR #667:
URL: https://github.com/apache/iceberg-python/pull/667#discussion_r1584763652


##########
pyiceberg/table/__init__.py:
##########
@@ -3537,6 +3537,39 @@ def update_partitions_map(
             schema=table_schema,
         )
 
+    def metadata_log_entries(self) -> "pa.Table":
+        import pyarrow as pa
+
+        from pyiceberg.table.snapshots import MetadataLogEntry
+
+        table_schema = pa.schema([
+            pa.field("timestamp", pa.timestamp(unit='ms'), nullable=False),
+            pa.field("file", pa.string(), nullable=False),
+            pa.field("latest_snapshot_id", pa.int64(), nullable=True),
+            pa.field("latest_schema_id", pa.int32(), nullable=True),
+            pa.field("latest_sequence_number", pa.int64(), nullable=True),
+        ])
+
+        def metadata_log_entry_to_row(metadata_entry: MetadataLogEntry) -> 
Dict[str, Any]:
+            latest_snapshot = 
self.tbl.metadata._snapshot_as_of_timestamp_ms(metadata_entry.timestamp_ms)
+            return {
+                "timestamp": metadata_entry.timestamp_ms,
+                "file": metadata_entry.metadata_file,
+                "latest_snapshot_id": latest_snapshot.snapshot_id if 
latest_snapshot else None,
+                "latest_schema_id": latest_snapshot.schema_id if 
latest_snapshot else None,
+                "latest_sequence_number": latest_snapshot.sequence_number if 
latest_snapshot else None,
+            }
+
+        # imitates `addPreviousFile` from Java, might could move this to 
`metadata_log` constructor

Review Comment:
   ```suggestion
           # imitates `addPreviousFile` from Java; this could move this to 
`metadata_log` constructor
   ```



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to