rdblue commented on code in PR #18526:
URL: https://github.com/apache/iceberg/pull/18526#discussion_r4672427251


##########
format/spec.md:
##########
@@ -610,6 +614,8 @@ Note that:
 * After upgrading, new snapshots in different branches will assign disjoint ID 
ranges to existing data files, based on the table's `next-row-id` when the 
snapshot is committed. For a data file in multiple branches, a writer may write 
the `first_row_id` from another branch or may assign a new `first_row_id` to 
the data file (to avoid large metadata rewrites).
 * Existing rows will inherit `_last_updated_sequence_number` from their 
containing data file.
 
+When a table is upgraded to v4, existing manifest lists and manifests are not 
rewritten. Manifest lists and manifests written before the upgrade do not have 
a `snapshot_timestamp` field and the field must be read as if it is `null`. 
When reading a manifest list written before v4, each manifest inherits the 
snapshot's `timestamp-ms` converted to microseconds, and entries in a manifest 
written before v4 inherit that manifest's `snapshot_timestamp`. As a result, 
rows in the table at the time of the upgrade have a `_last_updated_timestamp` 
equal to the `timestamp-ms` of the last snapshot before the upgrade, converted 
to microseconds.

Review Comment:
   This behavior differs from how we handle `_last_updated_sequence_number`. On 
upgrade, existing snapshots that do not have `first-row-id` produce null for 
`_last_updated_sequence_number` (see the [value 
reader](https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/avro/ValueReaders.java#L336-L343)).
 I think that we should have the same behavior here: when reading v3 snapshots 
the timestamps are all null. This ensures that rows from different table 
versions don't have inconsistent timestamp values: without this rule all rows 
from v3 and earlier always have the current snapshot's timestamp.
   
   Next, we need to set the value on upgrade. I still like the idea of using 
the previous snapshot's timestamp for all existing rows at the time of the 
upgrade. Since the committer knows the parent snapshot, it can be responsible 
for setting each manifest's timestamp value in the first commit after upgrade 
to the parent's timestamp.
   
   ```suggestion
   When a table is upgraded to v4, existing manifest lists and manifests are 
not rewritten. Manifest lists and manifests written before the upgrade do not 
have a `snapshot_timestamp` field so its value remains null. When reading a 
manifest list written before v4, each manifest's `snapshot_timestamp` remains 
unset or null so that the `_last_updated_timestamp` is null for all rows in v3 
snapshots. The `snapshot_timestamp` field for all existing manifests must be 
set in the first v4 commit to the parent snapshot's timestamp so that all 
existing rows have a `_last_updated_timestamp` from the last v3 snapshot.
   ```
   
   I also like the v3 wording above better, "(missing field) remains unset or 
null".



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