Goal C — Feature Parity with apache/iceberg-rust: Specification

  • Status: Proposed

  • Baseline: benodb-iceberg standalone format crate (Goal A/B complete, 4d37f586)

  • Reference implementation: apache/iceberg-rust

  • Scope rule: the public API of benodb does not change. Every path a downstream user can reach today keeps resolving for the duration of Goal C.


1. Objective

Close the gap between benodb-iceberg and apache/iceberg-rust so the crate is a complete, standalone Iceberg implementation in Rust — usable by third parties without the BenoDB engine — while the engine keeps its index-accelerated execution on top.

Parity is defined against iceberg-rust’s four subsystems that the crate lacks:

#

Subsystem

iceberg-rust module

BenoDB state today

C1

Catalog abstraction

iceberg::Catalog + REST/Hive/Glue/SQL/Memory impls

8 backends in the engine (core/catalog/), engine-coupled

C2

Expression / predicate model

iceberg::spec::Expression

None spec-shaped; the engine uses DataFusion Expr

C3

Scan planning

Table::scan + task generation

Engine-internal pruning (index-accelerated)

C4

Transactions

Transaction + TableRequirement/TableUpdate

Engine-internal OCC (commit_table_with_requirements exists on the trait)

Two further areas are explicitly out of scope for Goal C and listed in §8.


2. The asset inventory (what already maps)

The extraction work (Goal A/B) left the crate with the spec foundation both projects share: table metadata V2/V3, Avro manifests, schemas, transforms, values, delete files, deletion vectors, Puffin containers.

Three engine assets map onto the missing subsystems with less work than a from-scratch build:

  1. The Catalog trait (core/catalog/mod.rs) already has the iceberg-rust shape: namespace create/exists/drop, table create/drop/list/exists, load_table returning the crate’s TableMetadata, create_branch, and commit_table_with_requirements — the last maps directly onto iceberg-rust’s commit_table(TableRequirement, TableUpdate). The trait’s dependency direction is already correct: it returns crate types, not engine types.

  2. Eight catalog backends (REST, Glue, Hive, Unity, Nessie, JDBC, S3 Tables, Memory) with a shared real-service conformance suite and CAS parity (ADR-009).

  3. A pruning planner (core/planner.rs) with partition and statistics pruning, and a PruneReason explain surface — the raw material for spec-level scan planning.


3. C1 — The catalog layer

Goal: a Catalog trait in benodb-iceberg that third parties implement or consume, with the engine’s eight backends implementing it.

3.1 The trait

Move the trait into the crate as benodb_iceberg::catalog::Catalog, retyped to crate vocabulary:

pub trait Catalog: Send + Sync {
    async fn create_namespace(&self, namespace: &str) -> Result<()>;
    async fn namespace_exists(&self, namespace: &str) -> Result<bool>;
    async fn drop_namespace(&self, namespace: &str) -> Result<()>;
    async fn create_table(&self, namespace: &str, table: &str,
                          schema: &Schema, location: Option<&str>) -> Result<TableMetadata>;
    async fn drop_table(&self, namespace: &str, table: &str) -> Result<()>;
    async fn list_tables(&self, namespace: &str) -> Result<Vec<String>>;
    async fn load_table(&self, namespace: &str, table: &str) -> Result<TableMetadata>;
    async fn table_exists(&self, namespace: &str, table: &str) -> Result<bool>;
    async fn commit_table(&self, namespace: &str, table: &str,
                          requirements: &[TableRequirement],
                          updates: &[TableUpdate]) -> Result<TableMetadata>;
}

Differences from the engine’s trait, and why:

  • Schema is the crate’s spec schema, not Arrow’s SchemaRef. The engine’s trait takes SchemaRef because the engine thinks in Arrow; the spec catalog speaks the spec schema. The engine’s backends convert at the boundary (the conversion already exists — schema.rs’s iceberg_json_to_arrow_schema and its inverse).

  • commit_table takes requirements and updates — the Iceberg assertion model — instead of the engine’s ad-hoc commit payload. The engine’s commit_table_with_requirements already accepts requirements; the update list formalizes the other half.

  • Branch semantics stay (create_branch), as a default-no-op extension — Nessie’s branch model is a BenoDB differentiator worth keeping.

3.2 TableRequirement and TableUpdate

These two types (the assertion and update vocabulary of the Iceberg REST spec) move into the crate as spec types. The engine’s REST catalog already parses and emits them for the REST protocol; the types move, the parsing stays.

3.3 Backend adaptation

The eight backends stay in the engine (they are operationally configured — regions, endpoints, credentials — and the engine owns configuration). Each implements the crate’s trait. The work per backend is the trait retype: Arrow schema → spec schema at create_table, and the commit payload → requirements/updates at commit_table. The CAS parity suite (ADR-009) is the verification harness — it already runs every backend against real services.

3.4 What the engine keeps

The engine’s Catalog trait remains, implemented as a thin wrapper over the crate’s trait (or the reverse — the engine’s trait becomes the crate’s trait aliased). Every create_catalog path and the Python bindings keep their signatures.

Verification: the real-service catalog conformance suite (all eight backends), the CAS parity tests, and the SSRF/auth tests — all existing.


4. C2 — The expression / predicate model

Goal: the Iceberg spec’s predicate tree in the crate, with a DataFusion translation at the engine boundary.

4.1 The model

A new benodb_iceberg::expr module implementing the spec’s boolean model:

pub enum Expression {
    AlwaysTrue,
    AlwaysFalse,
    Not(Box<Expression>),
    And(Box<Expression>, Box<Expression>),
    Or(Box<Expression>, Box<Expression>),
    Predicate(Predicate),
}

pub struct Predicate {
    pub op: PredicateOp,   // IsNull, NotNull, Lt, LtEq, Gt, GtEq, Eq, NotEq,
                           // In, NotIn, StartsWith, NotStartsWith
    pub term: Term,        // ByFieldId(i32) — the spec addresses fields by id
    pub literal: Option<Literal>,
}

pub enum Literal { Boolean(bool), Int(i32), Long(i64), Float(f32), Double(f64),
                   String(String), Date(i32), TimestampMicros(i64), ... }

Design rules:

  • Terms are field ids (the spec’s addressing). Name resolution happens once at the boundary via the schema.

  • Literals are spec-typed, not JSON — the conversion from JSON/Avro already exists in value.rs.

  • The model is evaluable against partition values (needed for C3’s partition pruning) — Expression::test(&PartitionValues) -> bool using the transform-aware comparison the spec requires.

4.2 The DataFusion bridge (engine-side)

The engine’s FilterExpr(DataFusion(Expr)) stays as the execution vocabulary. The bridge is two functions in the engine, not the crate:

  • to_datafusion(expr: &Expression, schema: &SchemaRef) -> Expr — for pushing spec predicates into the engine’s execution.

  • from_datafusion(expr: &Expr, schema: &Schema) -> Option<Expression> — for exposing spec predicates outward (the REST scan API, C3).

The bridge is total in the to-direction (every spec expression has a DataFusion form) and partial in the from-direction (DataFusion expressions outside the spec’s vocabulary — UDFs, casts of arbitrary depth — return None rather than approximating).

Verification: round-trip property tests (spec → DataFusion → spec is identity on the spec’s vocabulary), evaluation tests against partition values, and the existing differential oracles once C3 wires predicates into the engine’s pruning.


5. C3 — Scan planning

Goal: Table::scan-style task generation from metadata + expression, as a crate-level API over the spec types.

pub struct ScanPlan {
    pub snapshots: Vec<SnapshotScan>,   // per-snapshot file tasks
}

pub struct FileScanTask {
    pub data_file: IcebergManifestEntry,
    pub delete_files: Vec<DeleteFile>,  // resolved per file
    pub partition: Option<PartitionValues>,
}

plan_file_scan(metadata, snapshot_id, predicate: Option<&Expression>) -> Result<ScanPlan>:

  1. Resolve the snapshot → manifest list → manifests (the crate’s Avro readers).

  2. Apply the predicate’s partition pruning: evaluate the expression against each file’s partition values (C2’s test), using the transform semantics already in transform.rs.

  3. Resolve delete files per data file (equality by file content, position by referenced path, DVs by field 143–145) — the matching logic the engine’s reader already implements, lifted to the crate.

  4. Column stats pruning (min/max against the predicate) as a second filter — the engine’s PruneReason taxonomy is the model for the explain surface.

What the engine keeps: its own index-accelerated execution. The engine’s planner gains a bridge: a spec Expression can be translated (C2) into the engine’s filter vocabulary, so third-party predicates flow into the indexed path. The engine’s scan remains strictly more capable (inverted bitmaps, BM25, HNSW); the crate’s scan plan is the portable subset.

Verification: the crate’s scan plan vs the engine’s full-scan oracle on the same snapshots (the WS1 differential pattern, applied at the crate level), plus the interop workflow.


6. C4 — Transactions

Goal: the assertion/update commit model as a crate-level API.

pub struct Transaction { requirements: Vec<TableRequirement>, updates: Vec<TableUpdate> }

impl Transaction {
    pub fn new(base: &TableMetadata) -> Self;
    pub fn add_schema(&mut self, schema: Schema) -> &mut Self;
    pub fn add_snapshot(&mut self, snapshot: IcebergSnapshot) -> &mut Self;
    pub fn set_properties(&mut self, props: HashMap<String, String>) -> &mut Self;
    pub fn upgrade_format_version(&mut self, v: i32) -> &mut Self;
    pub fn validate(&self, base: &TableMetadata) -> Result<()>;   // requirements vs base
    pub fn apply(self, base: TableMetadata) -> Result<TableMetadata>;
}
  • validate implements the requirement assertions (assert-table-uuid, assert-schema-id, assert-last-sequence-number, assert-ref-snapshot-id) — the vocabulary the engine’s REST catalog already parses.

  • apply produces the next TableMetadata — pure, total, unit-testable against the spec’s metadata template examples.

  • The engine’s OCC commit is the durability backend: the engine’s ManifestManager::commit gains a path that takes a validated Transaction’s output metadata. The engine’s crash-safety properties (M2 state machine, WAL, CAS) are unchanged — the transaction API is the vocabulary, the OCC is the mechanism.

Verification: the requirement/assertion unit tests against the spec’s examples, the M2 state machine suite (the transaction path drives the same commits), and the interop workflow.


7. Sequencing, effort, and verification

Stage

Content

Depends on

Size

Verification

C1

Catalog trait + requirements/updates types + backend adaptation

—

Medium (the trait is nearly movable; 8 backends retype)

Real-service conformance suite, CAS parity

C2

Expression model + DataFusion bridge

—

Medium (new code; the value conversions exist)

Round-trip properties, partition evaluation tests

C3

Scan planning

C2

Medium (the pruning logic exists engine-side to lift)

Crate-level differential oracle, interop

C4

Transactions

C1 types

Small-Medium (the requirement parsing exists)

Spec example tests, M2 suite

C1 and C2 are independent and can proceed in either order. C3 needs C2. C4 needs C1’s types. The engine’s gates (518 lib tests, M2 14/14, no-panic, workspace check) run at every stage; the interop workflow gates C3/C4.


8. Out of scope for Goal C

  1. Data file writers per spec (Parquet writer with spec name mapping) — the engine’s segment writer is the write path; a standalone spec writer is a separate project.

  2. Name mapping (field-id discovery for foreign Parquet files) — needed only for the standalone data writer; deferred with it.

  3. ORC/Avro data file formats — Parquet only, as the engine.

  4. V3 completeness beyond the bounded subset — variant types and the remaining deferred V3 features stay out of scope per SUPPORT_MATRIX.md, in both the crate and the engine.


9. Risks

  1. The catalog trait split. The engine’s trait and the crate’s trait must not fork. Mitigation: the engine’s trait becomes a type alias or a thin blanket impl over the crate’s; a compile error fires if they drift.

  2. Expression fidelity. The DataFusion bridge’s from-direction is partial by design; a predicate that cannot be represented must fail loudly, not silently narrow. Mitigation: from_datafusion returns None and callers reject with an explainable error.

  3. Scan-plan divergence. The crate’s plan and the engine’s execution must agree on file selection. Mitigation: the crate-level differential oracle (§5) runs in CI, not just at design time.