Repository navigation
GH-622: Modular footer thrift definition - #623
Jiayi-Wang-db wants to merge 4 commits into
Conversation
| 3: required parquet.CompressionCodec codec; | ||
| } | ||
|
|
||
| /** Exclusive element ends, not byte offsets; non-negative signed i32 values. |
There was a problem hiding this comment.
this doc makes no sense to me. could you try rephrasing, in a way that is useful to readers that are not faimiliar with the implementation?
There was a problem hiding this comment.
I likwise don't really understand the reference to "elements" or byte offsets. Gievn it is a struct, I don't understand the reference to i32 either 🤔
| /** BYTE_ARRAY; number of values = M; nullability: nullable. Aligned with keys. */ | ||
| 10: optional StreamLocation key_value_metadata_values; | ||
|
|
||
| /** Algorithm/AAD parameters and opaque footer-key metadata. |
There was a problem hiding this comment.
At least a few of the comments read a little bit like AI slop, could you please do a pass to make them more human readable.
| struct ModularFooter { | ||
| 1: required i32 version; // Allocation pending. | ||
|
|
||
| /** Exactly one of file_info and encrypted_file_info must be present. */ |
There was a problem hiding this comment.
nit: maybe place encrypted file_info next to file info?
| 3: optional StreamLocation boundary_orders; | ||
| } | ||
|
|
||
| /** Inline file metadata, plaintext or encrypted with the footer key. */ |
There was a problem hiding this comment.
encryption seems to live outside the sturct, maybe remove from the comment?
| struct FileInfo { | ||
| 1: required i32 num_columns; // Physical columns. | ||
| 2: required i64 num_rows; | ||
| 3: required list<parquet.SchemaElement> schema; |
There was a problem hiding this comment.
should this be its own stream, so we can change representation in the future?
There was a problem hiding this comment.
Do you mean move Schema into its own stream? I think it is a good idea, I stated it here https://docs.google.com/document/d/1xN4Nqh-fh-eH-cUz9e6Rqs_gPXRBKUh4s29EzX_NU8M/edit?tab=t.cbl5qtgc5xhz#heading=h.13suxwcajlet, it definitely helps with further reduce the footer size.
| /** Absolute file offset; relative to page_streams inside a column module. */ | ||
| 1: required i64 offset; | ||
|
|
||
| /** Stored bytes, including headers and protection. Signed streams append a |
There was a problem hiding this comment.
Should the encryption details be documented on the encryption structures. I assum the 28 bytes are incorporated into the lenght here so we don't need to know the detail?
|
|
||
| /** PageHeader/body pairs: [optional DICTIONARY_PAGE][DATA_PAGE_V2 ...]. | ||
| * Shared streams inherit root protection, including headers and dictionaries. | ||
| * Streams inside ColumnRowRangeStatistics are plaintext within its encrypted module. |
There was a problem hiding this comment.
This detail seems like it belongs in ColumnRowRangeStatistics?
| // Shared metadata structures. | ||
|
|
||
| /** PageHeader/body pairs: [optional DICTIONARY_PAGE][DATA_PAGE_V2 ...]. | ||
| * Shared streams inherit root protection, including headers and dictionaries. |
There was a problem hiding this comment.
What does root protection mean here?
|
|
||
| // Shared metadata structures. | ||
|
|
||
| /** PageHeader/body pairs: [optional DICTIONARY_PAGE][DATA_PAGE_V2 ...]. |
There was a problem hiding this comment.
Can we please try to use complete sentences.
e.g. a reasonable place to start for documenting this struct IIUC is "An in-file reference to series of parquet pages that store parquet metadata. The type of the data encoded varies by reference and is documented per field below. e.g. [optional DICTIONARY_PAGE][DATA_PAGE (V1 OR V2) ...]" Or are these specifically V2 data pages? We should document how the allowed set is controlled/versioned.
| * M = key/value pairs. K_c may vary, including zero, independently of G. | ||
| * Chunk membership alone does not determine row coverage. | ||
| * | ||
| * StreamLocation comments specify the scalar Parquet type, value count and |
There was a problem hiding this comment.
StreamLocation docs seem more appropriate on the struct itself?
|
|
||
| /** Modular footer supporting flexible data layouts and row-range statistics. | ||
| * | ||
| * C = physical columns; K_c = chunks in column c; K = sum(K_c). |
There was a problem hiding this comment.
nit: use set size to denote numbers and give an intro to these.
e.g.
C = |physical columns|
K_c = number of chunks in a column (a chunk is one contiguous set of data for the column)
....
There was a problem hiding this comment.
Also, the single letters can maybe be expanded a little bit to avoid making readers back-reference specific variables.
| * Streams/blocks precede the root and must not overlap. | ||
| * See the PME section for authentication and AAD rules. | ||
| */ | ||
| struct ModularFooter { |
There was a problem hiding this comment.
nit: if thrift supports it, we maybe should put this struct first so readers can see the high level view when reading the Thrift file.
| * Non-null streams: max RL=DL=0. Nullable streams: max RL=0, max DL=1 | ||
| * (DL=0: null; DL=1: present). No hierarchy repetition levels are stored. | ||
| * | ||
| * Chunk fields have K positions in column/chunk order; page fields have P |
There was a problem hiding this comment.
It seems like this could be distributed more locally for the most part.
| 1: required StreamLocation codecs; | ||
|
|
||
| /** INT32; number of values = K; nullability: nullable. | ||
| * Null means no dictionary; otherwise an ID in [0,D). Sharing is allowed |
There was a problem hiding this comment.
nit: I would maybe reverse this
A value at index 'i' is a dictionary ID, valid range [0, D), for chunk 'i'. Null means the chunk has no dictionary
I think in the design doc we should discuss the evolution dictionary sharing (we support it as soon as the new footer is supported)?
| /** INT32; number of values = K; nullability: nullable. | ||
| * Null means no dictionary; otherwise an ID in [0,D). Sharing is allowed | ||
| * only within one physical column, as determined by column_chunk_index. | ||
| * Every dictionary must be referenced and compatible with each referencing |
There was a problem hiding this comment.
I'm not sure I understand "including its codec". Is there a use-case for the dictionary being incompatible (i.e. does the sentence add value)?
| 2: required StreamLocation dictionary_ids; | ||
|
|
||
| /** BOOLEAN; number of values = K; nullability: non-null. | ||
| * True if all data pages use the chunk's dictionary; false without one. |
There was a problem hiding this comment.
| * True if all data pages use the chunk's dictionary; false without one. | |
| * True if all data pages use the chunk's dictionary; false when the chunk doesn't have a dictionary.. |
|
|
||
| /** INT64; number of values = K; nullability: non-null. | ||
| * Page headers + uncompressed bodies, counting the dictionary once per | ||
| * referencing chunk, even if shared. Omission means unknown sizes. |
There was a problem hiding this comment.
What does omission mean if not-null.
we should note this is the encoded size, this has been a source of confusion in the existing specificatin.
| 4: optional StreamLocation total_uncompressed_sizes; | ||
|
|
||
| /** INT64; number of values = K; nullability: non-null. | ||
| * Data-value counts including nulls; not row counts. |
There was a problem hiding this comment.
there was a recent thread on the mailing list about clarifying this. I think one conclusion we should note is that this value is equal to the number of definition/repetition levels written for the chunk when they apply (and it is equal to row count if the column is not nested and non nullable).
| 7: required StreamLocation offsets; | ||
|
|
||
| /** INT64; number of values = K; nullability: non-null. | ||
| * Stored data-page bytes, excluding dictionaries; non-negative, zero iff |
There was a problem hiding this comment.
what does excluding dictionaries mean here? I think a lot of other values above are non-negative, is there a reason you are specifically calling it out here?
There was a problem hiding this comment.
if there are other pages besides for dictionaries, those would be included as well. Could we maybe expand the definition/clarify what this is used for. e.g. The physical size of column chunk in the file.
| 4: optional StreamLocation num_values; | ||
|
|
||
| /** INT64; number of values = S; nullability: nullable. */ | ||
| 5: optional StreamLocation distinct_counts; |
There was a problem hiding this comment.
we need to clarify if this is mean to be an estimate or exact.
| /** INT64; number of values = S; nullability: nullable. */ | ||
| 5: optional StreamLocation distinct_counts; | ||
|
|
||
| /** Bound streams: [min_0, max_0, min_1, max_1, ...]; values independently nullable. |
There was a problem hiding this comment.
Why this rather then two independent streams? We expect most columns tstats columns to be sorted?
| } | ||
|
|
||
| /** Source of a statistics set's row ranges. */ | ||
| enum RowRangeKind { |
There was a problem hiding this comment.
if we want this to be forward compatible for new row ranges, I think it needs to be a union of Struct.
There was a problem hiding this comment.
I guess the only other addition I can think of here would be "fixed" width. so maybe we don't need forward compatibility but it would be a shame to break readers in the future just because they couldn't decode a stats enum.
| */ | ||
| struct SharedRangeStatistics { | ||
| /** INT64; number of values = C+1; nullability: non-null. | ||
| * Present iff statistics.range_kind is ARBITRARY. Non-decreasing, from 0 to S. |
There was a problem hiding this comment.
I think a little bit more english explanation would be useful here for arbitrary.
| * Shared streams inherit root protection, including headers and dictionaries. | ||
| * Streams inside ColumnRowRangeStatistics are plaintext within its encrypted module. | ||
| */ | ||
| struct StreamLocation { |
There was a problem hiding this comment.
nit: maybe a more descriptive name PageSequenceLocation? Maybe too verbose?
| */ | ||
| 8: optional list<SharedRangeStatistics> row_range_statistics; | ||
|
|
||
| /** BYTE_ARRAY; number of values = M; nullability: non-null. */ |
There was a problem hiding this comment.
should we have a member for M here, or we rely on the number of values in the page? Maybe package into its own struct. If M is only used here do we need to have an abbreviation for it or can we just document it?
| 1: required i32 num_columns; // Physical columns. | ||
| 2: required i64 num_rows; | ||
| 3: required list<parquet.SchemaElement> schema; | ||
| 4: optional string created_by; |
There was a problem hiding this comment.
maybe we should move key value tags here, so it is clear they need to be encrypted when the footer is encrypted?
| */ | ||
| 2: required parquet.ColumnCryptoMetaData crypto_metadata; | ||
|
|
||
| /** Absolute offset of the module's length prefix, before the root. */ |
There was a problem hiding this comment.
what does before the root here mean?
| 2: required parquet.ColumnCryptoMetaData crypto_metadata; | ||
|
|
||
| /** Absolute offset of the module's length prefix, before the root. */ | ||
| 3: required i64 offset; |
There was a problem hiding this comment.
should we be re-using stream here?
There was a problem hiding this comment.
Oh is this because this is pointing to the encrypted thrift metadata?
| * follow the schema. Module-type allocations are pending; do not reuse PME IDs. | ||
| */ | ||
|
|
||
| /** Compact-Thrift plaintext for one column-statistics module. |
There was a problem hiding this comment.
nit: Compact-Thrift plaintext seems confusing, I guess this to distinguish from compressed?
| */ | ||
| 1: required list<RangeStatistics> statistics; | ||
|
|
||
| /** All located streams, concatenated and encoded/compressed before encryption; |
There was a problem hiding this comment.
I think an example or more docs here would be useful, I don't understand what it is supposed to contain.
| 2: required StreamLocation lengths; | ||
| } | ||
|
|
||
| struct RowGroupMetadata { |
There was a problem hiding this comment.
The document says
"The Modular Footer allows each column to have its own number of chunks, with boundaries independent of row groups and other columns. "
If we are getting rid of row groups, why do we have RowGroupMetadata 🤔
| /** INT32; number of values = K; nullability: non-null. | ||
| * parquet.CompressionCodec values. | ||
| */ | ||
| 1: required StreamLocation codecs; |
There was a problem hiding this comment.
I wonder if inlining the codecs would be valuable as they are small and could let a reader quickly figure out if they supported something or not
There was a problem hiding this comment.
This seems like a strange carve out to me.
- codecs would compress really well with dictionary encoding and the dictionary is easily checkable today.
- Putting these out of line still allows a reader to do basic parsing if they don't support a codec to get at footer information.
On the balance I think leaving it out of line is better.
| 5: required StreamLocation num_values; | ||
|
|
||
| /** INT64; number of values = K; nullability: non-null. | ||
| * Absolute first rows; required for any COLUMN_CHUNK statistics, including |
There was a problem hiding this comment.
is this for each page? I don't understand how this is related to the PageMetadata below
| } | ||
|
|
||
| /** Independently optional streams sharing DataLayout.page_index; omit if both absent. */ | ||
| struct PageMetadata { |
There was a problem hiding this comment.
If we are changing ColumnChunk to store a sequence of pages and associated information, I don't understand the use of PageMetadata here
| // Footer directory. | ||
|
|
||
| /** Visible stream directory, including column-key descriptors. | ||
| * Layout: [source data][metadata streams and column-statistics blocks] |
There was a problem hiding this comment.
I don't really understand a lot of this 🤔 like what does
[u32 LE directory length][PAR3]
mean? If it is trying to explain the layout of the footer, I think an ascii art diagram would be more useful
|
Could we make sure we setup build infrastructure so we can ensure valid thrift. |
Addresses the follow-up on apache/parquet-format#623 r4483641306: replace C, K, P, D, G and S with named counts (num_columns, num_chunks, ...) so readers don't have to look back at the header. Comment-only change. Co-authored-by: Isaac <no-reply@databricks.com>
Comment-only follow-up for apache/parquet-format#623: - Start every stream field doc with its type and value count ("INT64, one value per chunk: ...") and split rules into paragraphs. - Move the column-chunk definition into the counts list, and the index "never means empty" note into DataLayout next to its example. - Fold the start() definition into the DataLayout range-ends paragraph. - Explain why RowGroupMetadata exists and what its absence means. - Simplify the ColumnChunkMetadata and dictionary_ids docs. - Document version, num_rows, created_by and file_info. Co-authored-by: Isaac <no-reply@databricks.com>
Comment-only follow-up for apache/parquet-format#623: - Drop standard Parquet details from StreamLocation (level encoding, null positions, V2 level compression) and the Thrift-optional note. - Explain that offsets inside ColumnRowRangeStatistics are relative because those streams live inside an encrypted module. - State that metadata stream compression is independent of column data compression. - Describe DataLayout indexes as running totals of chunks and pages. Co-authored-by: Isaac <no-reply@databricks.com>
Comment-only follow-up for apache/parquet-format#623: - State index value counts as "must" rules in DataLayout. - Describe column_chunk_index and page_index as inclusive prefix sums and drop details the struct doc already covers. - Move shared DictionaryMetadata rules to the struct doc, drop implied sentences and the first-use order recommendation. Co-authored-by: Isaac <no-reply@databricks.com>
…-group offsets Definition changes for apache/parquet-format#623: - Add DictionaryMetadata.codecs (field 3, required): the only source of a dictionary page's codec, so chunks with different codecs can share a dictionary. ColumnChunkMetadata.codecs now covers data pages only. - Make RowGroupMetadata.offsets required: the struct is present only when row groups are stored as contiguous byte ranges. - Move RangeStatistics.range_kind to the top of the struct (field ID 13 unchanged) and define the range kinds there. Doc changes: - total_uncompressed_sizes excludes the dictionary page. - num_values refers to ColumnMetaData.num_values. - Shorten RowGroupMetadata, chunk offsets/compressed_sizes, first_row_indexes, PageMetadata and relative_offsets docs. Co-authored-by: Isaac <no-reply@databricks.com>
Comment-only follow-up for apache/parquet-format#623: - RangeStatistics says whether its list covers all columns or one, and how a column without statistics is represented. - SharedRangeStatistics no longer repeats that rule. - Reword ModularFooter.row_range_statistics in plainer terms. Co-authored-by: Isaac <no-reply@databricks.com>
Definition changes for apache/parquet-format#623: - Replace the interleaved min_max_<type> streams with separate min_<type> and max_<type> streams, and min_max_is_exact with min_is_exact and max_is_exact. - Make RangeStatistics.range_kind required with no default. - Renumber RangeStatistics fields from 1 (range_kind first); update the AAD path example to [8, g, 2, 8] for min_int32. Doc changes: - RangeStatistics.num_values must not be written for COLUMN_CHUNK ranges. - Shorten range_kind, first_row_indexes, count and SharedRangeStatistics docs; keep the coverage rules only on range_kind. Co-authored-by: Isaac <no-reply@databricks.com>
Definition changes for apache/parquet-format#623: - Replace SharedRangeStatistics.column_range_starts (num_columns + 1 values) with column_range_index (num_columns values, inclusive prefix sum like DataLayout.column_chunk_index). - Make RangeStatistics.min_is_exact and max_is_exact required. Doc changes: - PME section now describes only how the modular footer differs from Encryption.md: footer modes, PAR3 magic, column-key statistics, and the AAD suffix. Use "encrypted column statistics" instead of "module". - Shorter crypto_metadata, encrypted_file_info and encrypted statistics field docs. - first_row_indexes explains range ends without columns, with an example. Co-authored-by: Isaac <no-reply@databricks.com>
Name-only change for apache/parquet-format#623 (field ID 2 unchanged): the field is the byte buffer that the StreamLocations in a column's encrypted statistics point into. Co-authored-by: Isaac <no-reply@databricks.com>
Comment-only follow-up for apache/parquet-format#623: the PME section now lists only the differences from Encryption.md as short bullets, explains column-key statistics in plain words, and describes the stream AAD path with an example. The encrypted column statistics structs get one-line field docs. Co-authored-by: Isaac <no-reply@databricks.com>
Comment-only follow-up for apache/parquet-format#623: an all-null column still has pages, so only empty files have columns without chunks. - DataLayout example uses 2, 1 and 3 chunks. - range_kind no longer mentions columns without chunks or pages, and scopes "no ranges" for missing statistics to ARBITRARY. - ColumnRowRangeStatistics.boundary_orders lines up with statistics. Co-authored-by: Isaac <no-reply@databricks.com>
Sync the reviewed modular footer definition, including separate bounds, fixed-length byte-array statistics, column orders, and clarified range semantics. Generate both schemas with make thrift and publish snapshots for either schema.
Rationale for this change
Support flexible data layouts and statistics over column-chunk, page, or arbitrary row ranges, while allowing readers to fetch placement and statistics independently.
What changes are included in this PR?
ModularFooter.thriftdefines a footer directory and independently readable metadata streams. Field comments specify stream types, value counts, nullability, and how columns map to chunks, pages, and statistics ranges.FIXED_LEN_BYTE_ARRAYcolumns, stored asBYTE_ARRAYto support different column widths.FileInfo.column_ordersdefines comparison order across shared and encrypted statistics; INT96 min/max statistics are unsupported.stream_data.PAR3; the length includes any directory signature.make thrift, and snapshot publishing triggered by changes to either Thrift schema.The definition uses the
ModularFooterroot and theparquet.modular/org.apache.parquet.format.modularnamespaces. Format-version and PME module-type allocations remain open. Maven source discovery already includes both schemas, and the build and CI use Thrift 0.24.0.Do these changes have PoC implementations?
The design and measurements describe the prototype readers and writers. Measurements cover plaintext metadata streams and pruning predicates; exact-count statistics, this directory serialization, encryption, and column sets are outside the measured scope. The linked design describes column sets as an optional extension for very wide files.
Validation:
make thriftgenerates both schemas using Apache Thrift 0.24.0. Generated C++ passes a syntax check with Thrift 0.24.0 headers, and all 83 generated Java source files compile with the cached Thrift 0.23.0 runtime. The importedparquet.thriftmatches the reviewed definition's dependency. Full Maven verification remains blocked by dependency resolution in this environment: offline verification cannot resolve the parent POM from the configured repository, and Maven Central DNS resolution fails.Related to #622.