Plaintext-footer encryption corrupts column metadata after the first row group

perfloop-oss/parquet-go · Uncatalogued correctness

https://perfloop.ai/t/oss/case_816ks6361k

Verdict

VERIFIED · settled 2026-11-24 · merged as parquet-go/parquet-go#751

What happened: The check fails before this change and passes with it.

Hypothesis

When modular encryption is configured with a plaintext footer, committing the first row group clears the reusable column chunk metadata struct in place. Every subsequent row group in the same file, and every file written after Reset, then encrypts a zeroed ColumnMetaData with Type=BOOLEAN, Codec=UNCOMPRESSED, and empty PathInSchema and Encoding. Plaintext-footer files with more than one row group or written from a reused writer therefore carry corrupted per-row-group column metadata that breaks compression and type inspection for Parquet readers.

In writer.go, newConcurrentRowGroupWriter (lines 911-926) initializes rg.columnChunk[i].MetaData with each column's immutable Type, Encoding, PathInSchema, and Codec and points c.columnChunk at &rg.columnChunk[i]. ColumnWriter.reset (lines 2119-2133) deliberately leaves those immutable fields intact between row groups. However, writer.writeRowGroup (lines 1776-1792) zeroes c.columnChunk.MetaData = format.ColumnMetaData{} in place when w.encryption != nil && !w.encryption.cfg.EncryptedFooter, before cloning rg.columnChunk into the committed row-group slice (lines 1855-1869). As a result, row group 0 encrypts valid metadata, while row group 1 onward and any file after Reset encrypt zeroed Type, Codec, PathInSchema, and Encoding.

A bounded 144-case search (TestHuntPlaintextFooterMetadataSearch in writer_plaintext_footer_metadata_hunt_test.go) exercised both footer modes (EncryptedFooter false/true), three codecs (Uncompressed, Snappy, Gzip), footer-only and per-column keys, data page versions 1 and 2, 1-3 row groups, and single-use vs Reset reuse. All 72 encrypted-footer controls and all 12 single-row-group non-reset plaintext-footer cases passed, while all 60 multi-row-group or post-Reset plaintext-footer cases failed with rg=1 col=0 MetaData.Type=BOOLEAN (want BYTE_ARRAY), Codec=UNCOMPRESSED (want GZIP/SNAPPY), PathInSchema=[], and Encoding=[]. The deterministic replay TestHuntPlaintextFooterMetadataReplay reproduces the failure on a two-row-group Gzip plaintext-footer file while passing the encrypted-footer control.

Upstream check: open PRs touching writer.go (#679, #554, #510) were inspected on 2026-11-24 and do not address plaintext-footer metadata zeroing.

Case proof target: confirm that committing plaintext-footer encrypted row groups preserves Type, Codec, PathInSchema, and Encoding across multiple row groups and Reset cycles while still clearing plaintext MetaData in the serialized footer. The test layout is provisional.

Change to test: Zero the plaintext MetaData only on the committed row-group copy stored in w.rowGroups rather than mutating the reusable rg.columnChunk entry in place, so subsequent row groups and reused writers preserve Type, Codec, PathInSchema, and Encoding before encrypting ColumnMetaData.

Where it lives

perfloop-oss/parquet-go · writer.go

Evidence

The check fails before this change and passes with it: `In plaintext-footer encrypted Gzip files with dictionary BYTE_ARRAY and plain INT64 columns, committing two row groups per file across two writer Reset cycles preserves decrypted Type, Codec, PathInSchema and Encoding while serialized footer column MetaData stays empty.`

Checks: 2 of 2 passed. Verification: no defect found.

Timeline