amogh-jahagirdar commented on code in PR #16025:
URL: https://github.com/apache/iceberg/pull/16025#discussion_r3606194180
##########
format/spec.md:
##########
@@ -685,21 +701,103 @@ The `manifest_entry` struct consists of the following
fields:
| | _optional_ | **`4 file_sequence_number`** | `long`
| File sequence number indicating
when the file was added. Inherited when null and status is 1 (added). |
| _required_ | _required_ | **`2 data_file`** | `data_file`
`struct` (see below) | File path, partition tuple,
metrics, ... |
-The manifest entry fields are used to keep track of the snapshot in which
files were added or logically deleted. The `data_file` struct, defined below,
is nested inside the manifest entry so that it can be easily passed to job
planning without the manifest entry fields.
+ The manifest entry fields are used to keep track of the snapshot in which
files were added or logically deleted. The `data_file` struct, defined below,
is nested inside the manifest entry so that it can be easily passed to job
planning without the manifest entry fields.
-When a file is added to the dataset, its manifest entry should store the
snapshot ID in which the file was added and set status to 1 (added).
+ When a file is added to the dataset, its manifest entry should store the
snapshot ID in which the file was added and set status to 1 (added).
-When a file is replaced or deleted from the dataset, its manifest entry fields
store the snapshot ID in which the file was deleted and status 2 (deleted). The
file may be deleted from the file system when the snapshot in which it was
deleted is garbage collected, assuming that older snapshots have also been
garbage collected [1].
+ When a file is replaced or deleted from the dataset, its manifest entry
fields store the snapshot ID in which the file was deleted and status 2
(deleted). The file may be deleted from the file system when the snapshot in
which it was deleted is garbage collected, assuming that older snapshots have
also been garbage collected [1].
-Iceberg v2 adds data and file sequence numbers to the entry and makes the
snapshot ID optional. Values for these fields are inherited from manifest
metadata when `null`. That is, if the field is `null` for an entry, then the
entry must inherit its value from the manifest file's metadata, stored in the
manifest list.
-The `sequence_number` field represents the data sequence number and must never
change after a file is added to the dataset. The data sequence number
represents a relative age of the file content and should be used for planning
which delete files apply to a data file.
-The `file_sequence_number` field represents the sequence number of the
snapshot that added the file and must also remain unchanged upon assigning at
commit. The file sequence number can't be used for pruning delete files as the
data within the file may have an older data sequence number.
-The data and file sequence numbers are inherited only if the entry status is 1
(added). If the entry status is 0 (existing) or 2 (deleted), the entry must
include both sequence numbers explicitly.
+ Iceberg v2 adds data and file sequence numbers to the entry and makes the
snapshot ID optional. Values for these fields are inherited from manifest
metadata when `null`. That is, if the field is `null` for an entry, then the
entry must inherit its value from the manifest file's metadata, stored in the
manifest list.
+ The `sequence_number` field represents the data sequence number and must
never change after a file is added to the dataset. The data sequence number
represents a relative age of the file content and should be used for planning
which delete files apply to a data file.
+ The `file_sequence_number` field represents the sequence number of the
snapshot that added the file and must also remain unchanged upon assigning at
commit. The file sequence number can't be used for pruning delete files as the
data within the file may have an older data sequence number.
+ The data and file sequence numbers are inherited only if the entry status
is 1 (added). If the entry status is 0 (existing) or 2 (deleted), the entry
must include both sequence numbers explicitly.
-Notes:
+ Notes:
-1. Technically, data files can be deleted when the last snapshot that contains
the file as “live” data is garbage collected. But this is harder to detect and
requires finding the diff of multiple snapshots. It is easier to track what
files are deleted in a snapshot and delete them when that snapshot expires. It
is not recommended to add a deleted file back to a table. Adding a deleted file
can lead to edge cases where incremental deletes can break table snapshots.
-2. Manifest list files are required in v2, so that the `sequence_number` and
`snapshot_id` to inherit are always available.
+ 1. Technically, data files can be deleted when the last snapshot that
contains the file as "live" data is garbage collected. But this is harder to
detect and requires finding the diff of multiple snapshots. It is easier to
track what files are deleted in a snapshot and delete them when that snapshot
expires. It is not recommended to add a deleted file back to a table. Adding a
deleted file can lead to edge cases where incremental deletes can break table
snapshots.
+ 2. Manifest list files are required in v2, so that the `sequence_number`
and `snapshot_id` to inherit are always available.
+
+=== "v4"
+ **Content Entries**
+
+ | Field id | Name | Type | Write | Read | Description |
+ |----------|------|------|-------|------|-------------|
+ | 134 | **`content_type`** | `int` (0: DATA, 2: EQUALITY DELETES, 3:
DATA_MANIFEST, 4: DELETE_MANIFEST) | *required* | *required* | Type of content
stored in the entry. Content types 3 and 4 are only valid in root manifests. |
+ | 157 | **`writer_format_version`** | `int` (0: PRE-V4, 4: V4) |
*required* | *required* | Writer format version. V4 writers must produce
`writer_format_version` 4. |
+ | 100 | **`location`** | `string` | *required* | *required* | Location of
the file or manifest. |
+ | 101 | **`file_format`** | `string` | *required* | *required* | String
file format name: `avro`, `orc`, `parquet`, or `puffin` |
+ | 147 | **`tracking`** | `tracking` struct | *required* | *required* |
Groups status, snapshot, and sequence number. See tracking struct below. |
+ | 141 | **`spec_id`** | `int` | *optional* | *optional* | ID of the
partition spec used to write this manifest or data file. |
+ | 140 | **`sort_order_id`** | `int` | *optional* | *optional* | ID
representing sort order for this file. |
+ | 103 | **`record_count`** | `long` | *required* | *required* | Number of
records in this file. |
+ | 104 | **`file_size_in_bytes`** | `long` | *required* | *required* |
Total file size in bytes. |
+ | 146 | **`content_stats`** | `content_stats` struct | *optional* |
*optional* | Column stats. See [Column Stats
Improvements](#column-stats-improvements). |
+ | 150 | **`manifest_info`** | `manifest_info` struct | *optional* |
*optional* | See manifest_info struct below. |
+ | 131 | **`key_metadata`** | `binary` | *optional* | *optional* |
Implementation-specific key metadata for encryption. |
Review Comment:
I think we'll need a separate key_metadata for DVs to preserve the current
V3 capabilities. I find it a bit questionable that we really need separate key
metadata for data + DVs, but I'm biasing towards avoiding regressions and
avoiding unreadable data on upgrade. If we wanted to consolidate encryption
keys on upgrade to v4, we'd have to have some complicated data rewrites on
upgrade and more generally there may be some security use cases where a
separate key for data + DV are warranted that we want to preserve to avoid
regression.
Pasting my message from a chat I had with @rdblue
> if there's V3 tables out there that have separate encryption keys for data
files and DV, on upgrade to V4 I think we would need to be able to have that
representation otherwise tables are potentially unreadable. So as much as I
want to simplify, just the chance of there being tables in this position w
different DV and data file keys that we may not know about makes it difficult.
Unless we impose some writer side requirement to decrypt and consolidate on a
shared encryption key on upgrade or something but that seems complciated and
would require rewriting data on upgrade which we want to avoid
--
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]