FilterRowWriter zeroes caller Row values in place during cleanup

perfloop-oss/parquet-go · Uncatalogued correctness

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

Verdict

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

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

Hypothesis

Writing rows through a filtered row writer silently zeroes every value inside the caller's matching rows. Any caller that inspects its rows after WriteRows or fans one batch out across multiple writers with MultiRowWriter receives corrupted all-null values for every row the filter matched.

In filter.go lines 52-69, filterRowWriter.WriteRows aliases caller rows directly into its staging array (`f.rows[i] = row`), and its deferred cleanup loops `clearValues(clear[i])` over `f.rows[:]`. In value.go lines 975-979, clearValues overwrites every element of the aliased []Value slice with zero Value{}. Because f.rows[i] is never set to nil, those caller slices also remain referenced in f.rows across calls and are zeroed again on subsequent calls when fewer rows match. Upstream open PRs on parquet-go/parquet-go were checked (no open PR modifies filter.go).

A bounded search across batch sizes {1, 2, 5, 42, 43, 85} and predicates {all, even, odd, none} for both direct WriteRows and MultiRowWriter(FilterRowWriter(w1, pred), w2) failed 34 cases (every non-empty matching case), turning matching rows into `[<null> ...]`. Running `go test . -run '^TestHuntFilterRowWriterInputPreservationReplay$' -count=1` deterministically reproduces both direct caller-row corruption and MultiRowWriter fanout corruption, and passes after replacing the deferred loop with `defer clear(f.rows[:])`.

The Case should verify that FilterRowWriter.WriteRows leaves caller Row slices unmodified across single-batch, multi-batch, repeated-call, and MultiRowWriter fanout workloads while dropping retained references in f.rows. The submitted test file layout is provisional.

Change to test: Clear the slice headers in f.rows (such as defer clear(f.rows[:])) instead of calling clearValues on each f.rows[i] element, so FilterRowWriter.WriteRows releases references to caller rows without zeroing the caller's Row backing arrays.

Where it lives

perfloop-oss/parquet-go

Evidence

The check fails before this change and passes with it: `With non-mutating predicates and fully consuming non-mutating downstream writers, FilterRowWriter.WriteRows preserves caller Row values across single-batch, multi-batch and repeated calls, including MultiRowWriter fanout.`

The check fails before this change and passes with it: `After FilterRowWriter.WriteRows returns, all of its staging Row slices are nil, including after a downstream write error and after subsequent smaller or empty calls.`

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

Timeline