anuragmantri commented on code in PR #16425: URL: https://github.com/apache/iceberg/pull/16425#discussion_r4782724378
########## format/spec.md: ########## @@ -1653,6 +1656,53 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +Starting in v4, some fields of a data file can be stored in separate column files, listed in the data file's [`column_files`](#column-file-fields), in addition to the data file itself. This section describes column files for data files. + +In this section: + +- The **previous entry** is the live entry of the data file before column files are added. +- An **updated field** is a field whose ID is in the `field_ids` of an added column file. +- An **updated row** is a row whose updated-field values were set by the update. Other rows keep their current values. + +A column file is a valid Iceberg data file: files must use valid Iceberg formats, schemas, and column projection. + +A column file must have the same row count as its data file. + +A column file stores the entire value of each field whose ID is in its `field_ids`. Each ID in `field_ids` must be the ID of a top-level field in the table schema used to write the column file, or the ID of a row lineage field required by [Adding Column Files](#adding-column-files). The `field_ids` of a column file may overlap with the field IDs of the data file. Which file a field is read from is determined by [Reading Column Files](#reading-column-files). + +#### Reading Column Files + +A projected field whose top-level field ID is in a column file's `field_ids`, including `_last_updated_sequence_number`, must be read from that column file. All other projected fields are read from the data file using [Column Projection](#column-projection). + +Row `i` of a column file corresponds to row `i` of the data file. Column files and the data file are combined by row position before the deletion vector is applied. Readers must ignore top-level fields in a column file whose IDs are not in its `field_ids`. A null value in a column file does not indicate that a row is deleted. + +#### Adding Column Files + +When column files are added to a data file, the writer must produce a MODIFIED entry and a REPLACED entry as described in [Updating Tracking Metadata](#updating-tracking-metadata). The MODIFIED entry and the REPLACED entry may be written to different manifests. + +A new column file stores the value of each of its listed fields for every row of the data file, including rows the update did not change. Values in rows deleted by the MODIFIED entry's `deletion_vector` should be null, so a top-level field must be optional in the column file's schema if the column file stores null for it. For a top-level field that is required in the table schema, a non-null value must be stored in every row that is not deleted by the MODIFIED entry's `deletion_vector`. + +The `tracking` fields of the MODIFIED entry are set as described in [Updating Tracking Metadata](#updating-tracking-metadata) and [Sequence Number Inheritance](#sequence-number-inheritance), and `tracking.snapshot_id` must be the previous entry's (inherited) snapshot ID. The other fields of the MODIFIED entry must match the previous entry, except for the following: + +- `spec_id` and `partition`: + - If an updated field is, or contains, a source field of the partition spec, `spec_id` and `partition` must be null. +- `sort_order_id`: + - If an updated field is, or contains, a field in the sort order, `sort_order_id` must be null. +- `content_stats`: + - Stats for each updated field, including its nested fields, must be computed from the values in the column file that has its ID in `field_ids`, or omitted. Stats for other fields may be kept. +- `deletion_vector`: Review Comment: > What is the point about the DV differing from the previous entry? Once a column file changes the data sequence number, existing delete files stop applying. That includes v2 position deletes and delete manifest DVs, not only equality deletes, so the writer has to fold them into the DV. I added that reason to the bullet. It isn't stated elsewhere for all delete types so I still think this bullet is required. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. Review Comment: Done. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. Review Comment: I added a sentence that name mapping is not allowed. Base files can still use name mapping though. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. +- If a struct changes between null and non-null in at least one such row, the added column files must be responsible for the struct and for every field nested in it. Review Comment: Done. Moved it to the null-state paragraph. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. Review Comment: Done. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. Review Comment: I removed the two rules, so this paragraph is not needed. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. +- If a struct changes between null and non-null in at least one such row, the added column files must be responsible for the struct and for every field nested in it. + +#### Reading Column Files + +Readers must read each field from the file responsible for it, which is the first of: Review Comment: Yes, I meant leaf field here. Made the change. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. +- If a struct changes between null and non-null in at least one such row, the added column files must be responsible for the struct and for every field nested in it. + +#### Reading Column Files + +Readers must read each field from the file responsible for it, which is the first of: + +1. The column file whose `field_ids` has the field's ID. +2. The file responsible for the field's parent. +3. The base file. + +Readers must ignore fields in a column file that it is not responsible for. Null values in a column file may represent deleted rows. + +A data file and its column files are read using [Column Projection](#column-projection). + +If a struct is null in a row, every field nested in it is null in that row. A reader may take the struct's null state from any file responsible for part of it. + +#### Tracking Column File Changes + +When a writer adds column files to a data file, the writer must produce a MODIFIED entry and a REPLACED entry as described in [Updating Tracking Metadata](#updating-tracking-metadata). The MODIFIED entry holds the new metadata. The REPLACED entry holds the previous metadata and may be produced in place using the leaf manifest's `manifest_info.dv`. The writer may write the two entries to different manifests. + +When a writer adds column files to a leaf manifest itself, replacing fields of the entries it tracks such as their `deletion_vector`, the writer must produce a MODIFIED entry and a REPLACED entry for the leaf manifest in the root manifest. The same commit may also change the leaf manifest's `manifest_info.dv`. + +When adding column files to a data file or a leaf manifest, the created entry must contain these changes compared to the REPLACED entry: Review Comment: I changed the tracking section to just link instead of restating here. I still think the deletion vector section is required. See my reasoning below. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. +- If a struct changes between null and non-null in at least one such row, the added column files must be responsible for the struct and for every field nested in it. + +#### Reading Column Files + +Readers must read each field from the file responsible for it, which is the first of: + +1. The column file whose `field_ids` has the field's ID. +2. The file responsible for the field's parent. Review Comment: Reworded slightly to "the column file whose field_ids has the ID of the field's nearest listed ancestor", since a field's nearest ancestor is always its parent. ########## format/spec.md: ########## @@ -1434,11 +1437,12 @@ When expiring snapshots, retention policies in table and snapshot references are #### Deleting Files -A file may be deleted from the file system when the snapshot in which it was deleted is garbage collected, assuming that the file is not live in any remaining snapshot [1]. +A file may be deleted from the file system when the snapshot in which it was deleted is garbage collected, assuming that the file is not live in any remaining snapshot [1], [2]. A Puffin file that stores deletion vectors is live while any of its deletion vectors is live. 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. When all snapshots are ancestors of a single branch, 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. Column files and deletion vector files are referenced from data file and leaf manifest metadata and are not tracked by their own manifest entries. Such a file is live in a snapshot if a live entry in that snapshot references it, including through a leaf manifest's column files. It may be deleted when it is not live in any remaining snapshot. Review Comment: I thought about this a bit more. I think "column files and co-located dvs" would make sense but the spec does not define what a colocated dv is so for now, I'm going with Ryan's suggestion. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. Review Comment: Agreed, I removed this line. ########## format/spec.md: ########## @@ -530,6 +531,8 @@ When an existing row is moved to a different data file for any reason, writers s Engines may model operations as deleting/inserting rows or as modifications to rows that preserve row ids. +When column files update the rows of a data file, `_last_updated_sequence_number` must also be updated: it must be `null` for each row the column files modify, and the existing non-null value must be copied for every other row that is not deleted (see [Tracking Column File Changes](#tracking-column-file-changes)). Review Comment: Done ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. +- If a struct changes between null and non-null in at least one such row, the added column files must be responsible for the struct and for every field nested in it. + +#### Reading Column Files + +Readers must read each field from the file responsible for it, which is the first of: + +1. The column file whose `field_ids` has the field's ID. +2. The file responsible for the field's parent. +3. The base file. + +Readers must ignore fields in a column file that it is not responsible for. Null values in a column file may represent deleted rows. + +A data file and its column files are read using [Column Projection](#column-projection). + +If a struct is null in a row, every field nested in it is null in that row. A reader may take the struct's null state from any file responsible for part of it. Review Comment: Makes sense. Applied. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. +- If a struct changes between null and non-null in at least one such row, the added column files must be responsible for the struct and for every field nested in it. + +#### Reading Column Files + +Readers must read each field from the file responsible for it, which is the first of: + +1. The column file whose `field_ids` has the field's ID. +2. The file responsible for the field's parent. +3. The base file. + +Readers must ignore fields in a column file that it is not responsible for. Null values in a column file may represent deleted rows. + +A data file and its column files are read using [Column Projection](#column-projection). Review Comment: I'm okay to remove this as every Iceberg read already uses this. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. +- If a struct changes between null and non-null in at least one such row, the added column files must be responsible for the struct and for every field nested in it. + +#### Reading Column Files + +Readers must read each field from the file responsible for it, which is the first of: + +1. The column file whose `field_ids` has the field's ID. +2. The file responsible for the field's parent. +3. The base file. + +Readers must ignore fields in a column file that it is not responsible for. Null values in a column file may represent deleted rows. Review Comment: Done. ########## format/spec.md: ########## @@ -1801,6 +1807,65 @@ If a delete column in an equality delete file is later dropped from the table, i Manifests hold the same statistics for delete files and data files. For delete files, the metrics describe the values that were deleted. +### Column Files + +In v4 and later, a data file or leaf manifest may store fields in column files listed in [`column_files`](#column-file-fields). The data file or leaf manifest whose `column_files` lists a column file is that column file's _base file_. + +A column file can use any supported Iceberg file format and must have the same row count as its base file. Its rows are aligned with the base file's rows by position, including deleted rows. + +A column file stores fields identified by field ID. If a field's ID is in a column file's `field_ids`, that column file is _responsible_ for the field and all fields nested in it. The base file is responsible for every field that no column file is responsible for. A field ID may be in the `field_ids` of at most one of a base file's column files, and `_row_id` must not be in any column file's `field_ids`. For example, a column file with `field_ids = [3, 5]`, where both fields are primitive, is responsible for fields 3 and 5. + +List, map, and file type fields are identified by their own ID. IDs of fields nested in these types, such as a list's element ID or a map's key and value IDs, must not be in `field_ids`. For example, for `8: tags list<9: string>`, `field_ids` may have 8 but not 9. + +When a struct's ID is in a column file's `field_ids`, the ID of a field nested in it may be in another column file's `field_ids`. That column file is then responsible for the nested field instead. For example, for `4: address struct<5: street, 6: city>`, if one column file stores all of `address` with `field_ids = [4]` and another's is `[5]`, the second file is responsible for `street` and the first for `address` and `city`. + +Every file that is responsible for part of a struct, including the base file, must store the same null state for that struct in each row. For example, for `4: address struct<5: street, 6: city>`, if one column file's `field_ids` is `[4]` and another's is `[5]`, and the first stores `address` as null in a row, the second must also store `address` as null in that row. + +#### Writing Column Files + +A column file stores a value for every row of its base file, including rows whose values did not change. Values for deleted rows should be null. A column file may write a field as optional even if that field is required in the table schema. + +In addition to the requirements above, writers adding column files must follow these rules. When checking a rule for a field, consider only rows where none of the structs that contain that field is null after the update. + +- The added column files must be responsible for each non-struct field whose value changes in at least one such row. +- If a struct changes between null and non-null in at least one such row, the added column files must be responsible for the struct and for every field nested in it. + +#### Reading Column Files + +Readers must read each field from the file responsible for it, which is the first of: + +1. The column file whose `field_ids` has the field's ID. +2. The file responsible for the field's parent. +3. The base file. + +Readers must ignore fields in a column file that it is not responsible for. Null values in a column file may represent deleted rows. + +A data file and its column files are read using [Column Projection](#column-projection). + +If a struct is null in a row, every field nested in it is null in that row. A reader may take the struct's null state from any file responsible for part of it. + +#### Tracking Column File Changes + +When a writer adds column files to a data file, the writer must produce a MODIFIED entry and a REPLACED entry as described in [Updating Tracking Metadata](#updating-tracking-metadata). The MODIFIED entry holds the new metadata. The REPLACED entry holds the previous metadata and may be produced in place using the leaf manifest's `manifest_info.dv`. The writer may write the two entries to different manifests. Review Comment: Sure, done. -- 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]
