≈ The Lake

Part 11 · Appendices · Chapter 38

How to read the specs

A guide to PROTOCOL.md, the Iceberg spec and parquet-format: how each is organized, how it expresses versions and compatibility, and how to get from a sentence in it to the code that implements it.

complete ~20 min

After this chapter you should be able to:
  • Find the normative requirement for a given behavior in each spec.
  • Apply each spec's compatibility rule: Delta's protocol gate, Iceberg's requirement tables, Parquet's annotation fallback.
  • Map spec sections to reference implementation classes.

Every chapter in this book cites one of three documents. They differ in age, governance and style, but they solve the same problem: letting independent implementations read and write the same files without coordinating. This chapter is a reader’s guide to them: where things are, how each expresses what a reader or writer must do, and how each lets the format evolve without breaking old clients. Each spec’s compatibility rule is small enough to state as a function, and src/sim/specs/reading.ts does that, with tests.

Delta PROTOCOL.md

Shape. One Markdown file at the root of the delta-io/delta repository, with a generated table of contents at the top.[PROTOCOL.md: table of contents] It reads in this order:

  1. Overview states the goals (serializable writes, snapshot isolation, scale to billions of files, self-describing, incremental processing) and the two-phase write: write data files, then commit a log entry.[PROTOCOL.md: Overview]
  2. Delta Table Specification defines a snapshot, the file types (data, DV, CDC, log entries, checkpoints, log compaction, _last_checkpoint, checksum) and the Actions with their field tables. Chapters 9 and 11 live here.
  3. Action Reconciliation is the replay rule, the most important page for a reader.
  4. Table Features, then one top-level section per feature (column mapping, deletion vectors, catalog-managed tables, IcebergCompat, row tracking, type widening and so on), each ending in Writer Requirements and Reader Requirements subsections.
  5. Additional Requirements for Writers (creating log entries, checkpoints, metadata cleanup, constraints, generated and identity columns) and Requirements for Readers.[PROTOCOL.md: Additional Requirements for Writers]
  6. Table Properties and the Appendix: valid feature names, the DV format, per-file statistics, partition value serialization, the schema JSON, the checkpoint schema.[PROTOCOL.md: Appendix]

How it evolves. Two integers and, past certain values, two lists. A table records minReaderVersion and minWriterVersion; at reader version 3 and writer version 7 it also lists readerFeatures and writerFeatures. A reader must implement every listed reader feature; a writer must implement every listed writer feature, and every reader feature, because it reads before it writes.[PROTOCOL.md: Table Features] Reader features are listed in both lists, and listing one only in readerFeatures is not allowed. The gate is small:

function deltaCanRead(p, c) {
  if (p.minReaderVersion > c.readerVersion) fail('reader version');
  if (p.minReaderVersion === 3) for (const f of p.readerFeatures) if (!c.features.includes(f)) fail(f);
}
function deltaCanWrite(p, c) {
  deltaCanRead(p, c);
  if (p.minWriterVersion > c.writerVersion) fail('writer version');
  if (p.minWriterVersion === 7) for (const f of p.writerFeatures) if (!c.features.includes(f)) fail(f);
}

Two more rules complete the picture. Supported is not active: appendOnly in writerFeatures makes a table append-only only when delta.appendOnly is also true. And anything a client does not recognize is safe to skip, because “breaking changes must be accompanied by an increase in the protocol version recorded in a table or by the addition of a table feature”. Clients must ignore unrecognized fields.[PROTOCOL.md: Protocol Evolution] Chapter 12 has the full feature model, including how legacy versions imply features.

Quiz Check: PROTOCOL.mdAnswers are scheduled for spaced review on the Review page.

Q1. A Delta table lists identityColumns in writerFeatures only. A reader that does not know identityColumns reads it. What should happen?

How sure are you?

Q2. appendOnly is in writerFeatures, but delta.appendOnly is not set. Is the table append-only?

How sure are you?

Q3. A Delta reader finds an action field it does not recognize. What does the protocol say?

How sure are you?

Iceberg spec

Shape. format/spec.md in apache/iceberg. It opens with Format Versioning: versions 1, 2 and 3 are “complete and adopted by the community”, and version 4 is “under active development and has not been formally adopted”.[Iceberg spec: Format Versioning] Then Goals and an Overview (optimistic concurrency, sequence numbers, row-level deletes, file system operations), and the Specification proper: schemas and types, partitioning, sorting, manifests, snapshots, manifest lists, scan planning, references, table metadata, commit conflict resolution, delete formats. Appendices A to G cover per-file-format rules (Avro, Parquet, ORC), the 32-bit hash, JSON serialization, single-value serialization, format version changes (Appendix E), implementation notes and geospatial notes.[Iceberg spec: Appendix E] The REST catalog is not in this file: it is an OpenAPI document, open-api/rest-catalog-open-api.yaml (chapter 21).[rest-catalog-open-api.yaml]

How it evolves. A table has one integer, format-version. The number goes up “when new features are added that will break forward-compatibility”. Inside a version, compatibility is carried by the field tables. Each field in a manifest, manifest list or metadata file has a requirement per version, and the spec defines what writers and readers do with each:[Iceberg spec: Writer requirements]

requirementwriter
(blank)the field should be omitted
optionalthe field can be written or omitted
requiredthe field must be written

Readers are more permissive, because “v1 metadata files are allowed in v2 tables (or later) so that tables can be upgraded to without rewriting the metadata tree”. For manifests and manifest lists, a field required in v2 but not in v1 is read as optional; only a field required in both versions makes a reader “fill in a default or throw an exception”. A version not shown inherits the most recent requirement shown. Appendix E then lists, per version, what writers stop writing and what readers default: for example, sequence numbers default to 0 when reading v1 metadata. Metadata JSON may be read strictly, since it is never reused across versions.

Quiz Check: the Iceberg specAnswers are scheduled for spaced review on the Review page.

Q1. When does Iceberg increment the format version?

How sure are you?

Q2. A manifest-list field is blank in v1 and required in v2. How does a v2 reader treat it?

How sure are you?

Q3. Where does the Iceberg spec list what changed between format versions and how to default new fields?

How sure are you?

parquet-format

Shape. A repository, not a single document. README.md gives the motivation, glossary, file layout, metadata, types, nested encoding, pages, column chunks, checksums and error recovery. Encodings.md, LogicalTypes.md, Compression.md and others each go deep on one topic. The project “contains format specifications and Thrift definitions of metadata required to properly read Parquet files”, and implementations such as parquet-java live elsewhere.[parquet-format README: Modules]

The Thrift file is the source of truth for bytes. Every footer and page-header structure is defined in parquet.thrift, and “all thrift structures are serialized using the TCompactProtocol”.[parquet-format README: Metadata] When the prose and the IDL seem to disagree about a field, the IDL decides what is on disk. Chapter 5 reads a footer field by field from it.[parquet.thrift]

How it evolves. There is no table-level version gate. Instead, the format is extensible in specific places: the file metadata carries a version, encodings are an enum that can grow, unknown page types “can be added and safely skipped”, and Thrift field id 32767 of every struct is reserved for extensions.[parquet-format README: Extensibility] Type annotations show the pattern most clearly. The old ConvertedType enum could not carry parameters, so LogicalType replaced it. Writers must write LogicalType and also the matching ConvertedType, for old readers. Readers use LogicalType, fall back to ConvertedType when no LogicalType is present, and for an unrecognized logical type “should ignore both the logical type annotation and column order for that column”, using only the physical type.[LogicalTypes.md: Compatibility]

Quiz Check: parquet-formatAnswers are scheduled for spaced review on the Review page.

Q1. Where is the authoritative definition of a Parquet footer's structures?

How sure are you?

Q2. A reader meets a LogicalType it does not recognize on a column that also has a ConvertedType. What should it use?

How sure are you?

From a sentence to the code

None of the three declares RFC 2119 keywords. The Iceberg spec at the pin has no capitalized MUST or SHOULD at all. PROTOCOL.md uses lowercase must for most requirements and capitalized MUST, SHOULD and MAY in some newer sections such as Table Properties. Read lowercase must and should as normative.

The method this book uses to get from a sentence to code:

  1. Pin the commit. Specs change on their default branches, and line anchors drift with every edit. Every link here uses a full SHA.
  2. Find the requirement subsection. In PROTOCOL.md that is the feature’s Writer Requirements or Reader Requirements; in the Iceberg spec, the field table and Appendix E; in parquet-format, the Thrift struct plus the topic file.
  3. Search the reference implementation for the field or feature name. The JSON field names in PROTOCOL.md (deletionVector, baseRowId) and the Iceberg field names (sequence_number, first_row_id) appear verbatim in the code: Delta’s actions are case classes in actions.scala, Iceberg’s are in api and core, Parquet’s are Thrift-generated classes used by parquet-java.
  4. Prefer the spec when they differ, and say so. Chapter 22 found IcebergCompatV3 in Delta’s code but not in PROTOCOL.md, and chapter 24 found Unity Catalog’s Iceberg REST endpoint vending credentials under a different check than its own API. Both are implementation behavior, and the book labels them that way.
Trace a requirement from the spec to code
  1. Pin the revision Use a stable commit for both the spec and source.
  2. Find the rule Identify the relevant reader or writer requirement and the metadata field it governs.
  3. Follow the field Search for the field name and trace where code writes it or makes decisions from it.
The spec gives the compatibility contract. The source explains how a particular implementation meets it.

The spec map in the lab below lists the anchors this book uses for its main claims, with the chapter that explains each.

Quiz Check: reading methodAnswers are scheduled for spaced review on the Review page.

Q1. Do PROTOCOL.md and the Iceberg spec use RFC 2119 capitalized keywords for requirements?

How sure are you?

Try it

  • Spec map: filter by spec, or search for “checkpoint” or “commit”, and follow a row from behavior to spec section to code.
  • Iceberg requirements: set v1 to blank and v2 to required, then both to required, and compare the reader rule.
  • Delta protocol gate: untick deletionVectors in the client and see both read and write fail. Then add identityColumns to the table’s writer features and see only writing fail.
  • Parquet annotations: set LogicalType to GEOMETRY with UTF8 as ConvertedType and untick “reader knows this LogicalType”.
behaviorspec sectionimplementation
Which actions survive log replay chapterDelta: Action ReconciliationInMemoryLogReplay.append
Which files make up a snapshot (log segment) chapterDelta: Delta Log Entries; CheckpointsSnapshotManagement.getLogSegmentForVersion
Creating version N+1 atomically chapterDelta: Creation of New Log EntriesOptimisticTransaction retry loop
Checkpoint naming and choosing the newest complete one chapterDelta: Checkpoint Naming SchemeCheckpoints: the latest complete checkpoint
Whether a client may read or write a table chapterDelta: Protocol Evolution; Table FeaturesProtocol checks in actions.scala
Deletion vector descriptor and bitmap format chapterDelta: Deletion Vectors; Deletion Vector FormatCodec (the Z85 encoding of inline DVs and UUIDs)
Commits ratified by a catalog chapterDelta: Catalog-managed tablesAbstractBatchBackfillingCommitCoordinatorClient.commit
Swapping the metadata pointer and retrying chapterIceberg: Optimistic ConcurrencySnapshotProducer.commit
Manifest list and manifest entries of a new snapshot chapterIceberg: Snapshots; ManifestsSnapshotProducer.apply
Pruning manifests and files during planning chapterIceberg: Scan PlanningManifestGroup
Validating concurrent row-level changes chapterIceberg: Commit Conflict Resolution and RetryMergingSnapshotProducer validations
Commit requirements and updates over HTTP chapterIceberg: REST catalog OpenAPI: updateTableCatalogHandlers.commit
Footer layout: FileMetaData, row groups, column chunks chapterParquet: File format; parquet.thrift FileMetaDataparquet.thrift FileMetaData
The RLE / bit-packing hybrid chapterParquet: Encodings.md: RLE = 3RunLengthBitPackingHybridEncoder
Min/max statistics and their sort order chapterParquet: Sort Order; Statistics structparquet.thrift Statistics

Summary

  • PROTOCOL.md is one file: actions, reconciliation, then one section per table feature with writer and reader requirements, then an appendix of formats. Compatibility comes from two versions plus readerFeatures and writerFeatures; unknown fields must be ignored.
  • The Iceberg spec has one format version per table, field tables with per-version requirements, and Appendix E for what changes between versions. Readers are deliberately more permissive than writers. The REST catalog is a separate OpenAPI file.
  • parquet-format is a repository whose Thrift IDL defines the bytes. It evolves through extensible enums, skippable page types, a reserved extension field, and the LogicalType-then-ConvertedType fallback.
  • To trace a sentence to code: pin the SHA, find the requirement subsection, search the implementation for the field name, and label any place where the code and the spec differ.

Primary sources

Review this chapter

This chapter has 9 quiz questions.

Review this chapter's cards → Review all due cards