← Back to Pull requests

fix(metadata): write and detect gzip-compressed table metadata #1014

Closed
unknown closed this pull request without merging on Oct 21, 2026 16:11 UTC
View on GitHub
unknown unknown commented on Oct 14, 2026 05:37 UTC
Author

What

With write.metadata.compression-codec=gzip, metadata files are named <version>-<uuid>.gz.metadata.json, but TableMetadataUtil::Write stored plain JSON in them, and Codec::FromFileName misdetected the codec: find_last_of(".metadata.json") searches for any one character of that string, so a .gz.metadata.json name was classified as uncompressed. The two bugs cancelled out inside iceberg-cpp, while files exchanged with Java failed in both directions.

Closes #1013.

How

  • FromFileName uses rfind, matching Java's lastIndexOf(".metadata.json"). Names without .metadata.json are now rejected, as in Java.

  • Write compresses the JSON when the location's codec is gzip, matching Java's internalWrite. This adds a GZipCompressor next to GZipDecompressor in util/gzip_internal.h, plus a kCompressError error kind alongside kDecompressError. Inputs above zlib's 32-bit length limit are rejected instead of being silently truncated.
  • The two changes are in one PR because neither works alone: fixing only the read side would make iceberg-cpp try to inflate the plain JSON it writes today.

    Tables that already have write.metadata.compression-codec=gzip and were written by iceberg-cpp contain plain JSON under .gz.metadata.json names; after this change iceberg-cpp reads those as gzip and fails, as Java already does. The property defaults to none.

    Testing

    New tests in metadata_io_test.cc:

  • CodecFromFileGzMetadataJson, CodecFromFilePlainAndLegacyGz, CodecFromFileInvalidName: codec detection for the .gz.metadata.json, plain, legacy .metadata.json.gz, and invalid names.

  • RoundTripGzipCompressedMetadata: writes with the gzip codec, checks the file name, checks that the bytes on disk start with the gzip magic 1f 8b, and reads the metadata back.
  • New tests in gzip_decompress_test.cc: GZipCompressorRoundTrip (100 KiB, more than one output buffer), GZipCompressorEmptyInput, and GZipCompressorReused (one compressor, two payloads, each decompresses on its own).

    Reverting the rfind change fails the three codec tests and the round trip; removing the write-side compression fails the round trip.

    Diff: 272 lines (+204 / -68) across 3 files Reviewer: LuciferYang Review duration: 10713m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 272 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.336
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1014"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.5% (MEDIUM) · Higher = larger blast radius
    39.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.1% · Safe to merge
    17.1%