laskoviymishka commented on code in PR #2761:
URL: https://github.com/apache/iceberg-go/pull/2761#discussion_r4731988985


##########
cmd/iceberg/snapshots_test.go:
##########
@@ -96,6 +96,23 @@ func TestBuildSnapshotEntries(t *testing.T) {
        assert.Nil(t, entries[1].ParentSnapshotID)
 }
 
+func TestSnapshotTimestampRoundTripsThroughRollback(t *testing.T) {
+       tbl := upgradeRollbackTestTable(t)
+       entry := buildSnapshotEntries(tbl)[0]
+       require.Equal(t, int64(200), entry.SnapshotID)
+
+       snapshotID, err := resolveRollbackSnapshotID(tbl, &RollbackCmd{
+               TableID:   "db.events",
+               Timestamp: entry.Timestamp,
+       })
+       require.NoError(t, err)
+       require.Equal(t, entry.SnapshotID, snapshotID)

Review Comment:
   Should this also assert the string itself? The round trip catches the 
regression, but nothing pins `entry.Timestamp`, and the fixtures only use 
`.770` ms. Something like `require.Equal(t, "2019-04-12T20:29:15.77Z", 
entry.Timestamp)` (or `.770Z` with a fixed layout) would lock in whichever 
format we keep.



##########
cmd/iceberg/snapshots.go:
##########
@@ -80,7 +80,7 @@ func buildSnapshotEntries(tbl *table.Table) []SnapshotEntry {
 
                entries = append(entries, SnapshotEntry{
                        SnapshotID:       s.SnapshotID,
-                       Timestamp:        
time.UnixMilli(s.TimestampMs).UTC().Format(time.RFC3339),
+                       Timestamp:        
time.UnixMilli(s.TimestampMs).UTC().Format(time.RFC3339Nano),

Review Comment:
   Could this use a fixed `.000` layout instead? `RFC3339Nano` trims trailing 
zeros, so the `timestamp` value is now `…15Z`, `…15.7Z` or `…15.77Z` depending 
on the row, where `main` always printed `…15Z`. A fixed layout keeps one shape 
for scripts reading the JSON and still parses in `parseRollbackTimestamp`.
   
   ```suggestion
                        Timestamp:        
time.UnixMilli(s.TimestampMs).UTC().Format("2006-01-02T15:04:05.000Z07:00"),
   ```



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