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


##########
format/spec.md:
##########
@@ -542,13 +544,15 @@ A data file with only new rows for the table may omit the 
`_last_updated_sequenc
 
 On read, if `_last_updated_sequence_number` is `null` it is assigned the 
`sequence_number` of the data file's manifest entry. The data sequence number 
of a data file is documented in [Sequence Number 
Inheritance](#sequence-number-inheritance).
 
+`_last_updated_timestamp` is set in the same way as 
`_last_updated_sequence_number`. On read, if `_last_updated_timestamp` is 
`null` it is assigned the `snapshot_timestamp` of the data file's tracking 
metadata, documented in [Snapshot Timestamp 
Inheritance](#snapshot-timestamp-inheritance).

Review Comment:
   Done.



##########
format/spec.md:
##########
@@ -1237,6 +1243,20 @@ Inheriting sequence numbers through the metadata tree 
allows writing a new manif
 
 Inheritance does not apply to v1, which does not have inherited fields like 
sequence number. When reading v1 manifests with no sequence number column, 
sequence numbers for all files must default to 0.
 
+##### Snapshot Timestamp Inheritance
+
+In v4 and later, the `snapshot_timestamp` tracking field records the 
`timestamp-ms` of the snapshot that added or last modified a file's data, 
converted to microseconds. It is used to assign `_last_updated_time` for [row 
lineage](#row-lineage).
+
+Writers must set `tracking.snapshot_timestamp` for data file and leaf manifest 
entries as follows:
+
+* An ADDED entry must have a `null` `snapshot_timestamp`.
+* An entry MODIFIED by column files must have a `null` `snapshot_timestamp`.

Review Comment:
   No problem, the split bullets are clearer. Replied in 
https://github.com/apache/iceberg/pull/18526#discussion_r4672529676.



##########
format/spec.md:
##########


Review Comment:
   Updated, and also added `_last_updated_timestamp` to the "may omit" sentence 
below.



##########
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:
   Agreed, applied your suggestion, with "v3" generalized to pre-v4 since 
tables can also upgrade from v1 or v2. It keeps `_last_updated_timestamp` 
consistent across snapshots regardless of format version, and matches how row 
lineage behaves after a v3 upgrade.
   
   The first v4 commit may also move pre-v4 data files directly into the root 
manifest. Those need the parent snapshot's timestamp written explicitly too. So 
I changed the last sentence to "In the first v4 commit, the 
`snapshot_timestamp` of each existing manifest or data file written to the root 
manifest must be set to the parent snapshot's timestamp". 



##########
format/spec.md:
##########
@@ -1237,6 +1245,17 @@ Inheriting sequence numbers through the metadata tree 
allows writing a new manif
 
 Inheritance does not apply to v1, which does not have inherited fields like 
sequence number. When reading v1 manifests with no sequence number column, 
sequence numbers for all files must default to 0.
 
+##### Snapshot Timestamp Inheritance
+
+The `snapshot_timestamp` tracking field records the `timestamp-ms` of the 
snapshot that added or last modified a file's data, converted to microseconds. 
It is used to assign `_last_updated_timestamp` for [row lineage](#row-lineage).
+
+When writing a manifest, writers must set `snapshot_timestamp` as follows:

Review Comment:
   I'd keep the explicit bullets. An ADDED entry can carry an explicit 
`sequence_number` (e.g. compaction keeping the older data sequence number), but 
its `snapshot_timestamp` must still be `null`.



##########
format/spec.md:
##########
@@ -1237,6 +1245,17 @@ Inheriting sequence numbers through the metadata tree 
allows writing a new manif
 
 Inheritance does not apply to v1, which does not have inherited fields like 
sequence number. When reading v1 manifests with no sequence number column, 
sequence numbers for all files must default to 0.
 
+##### Snapshot Timestamp Inheritance
+
+The `snapshot_timestamp` tracking field records the `timestamp-ms` of the 
snapshot that added or last modified a file's data, converted to microseconds. 
It is used to assign `_last_updated_timestamp` for [row lineage](#row-lineage).
+
+When writing a manifest, writers must set `snapshot_timestamp` as follows:
+
+* An ADDED entry or an entry MODIFIED by column files must have a `null` 
`snapshot_timestamp`.

Review Comment:
   Agreed, the split is clearer. Applied, with one tweak to the DV-update 
bullet: "must preserve the original non-null value".



##########
format/spec.md:
##########
@@ -952,6 +958,7 @@ The contents of a file are part of a snapshot if its 
tracking `status` is **live
     | _optional_ | 5        | **`modified_snapshot_id`**    | `long`           
                                                   | Snapshot ID where the file 
was last modified. |
     | _optional_ | 3        | **`sequence_number`**         | `long`           
                                                   | Data sequence number of 
the file. Inherited when null. See [Sequence Number 
Inheritance](#sequence-number-inheritance). |
     | _optional_ | 4        | **`file_sequence_number`**    | `long`           
                                                   | File sequence number 
indicating when the file was added. Inherited when null. See [Sequence Number 
Inheritance](#sequence-number-inheritance). |
+    | _optional_ | 8        | **`snapshot_timestamp`**      | `timestamptz`    
                                                   | `timestamp-ms` of the 
snapshot that added or last modified the file's data, in microseconds. 
Inherited when null. See [Snapshot Timestamp 
Inheritance](#snapshot-timestamp-inheritance). |

Review Comment:
   Applied.



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