Fix cache_parquet non-enumerable predicate reads and wildcard writes #65
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 457 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.367
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #65"
general
weight: 0.35
timkpaine
Summary
Fixes a family of
cache_parquetcorrectness bugs (all reproduced onmain) around non-enumerable partition predicates and the CACHE-mode write invariant. Found during the at-scale stress testing of the cache family.The read bug
With
date_column=None(extra-partition-columns-only mode), a read whose partition predicate can't be enumerated to a finite set of values — a negative predicate (col != x) or an unbounded range — returned 0 rows even though the data was cached:| predicate (populated cache,
extra_partition_cols=["symbol","region"]) | before | after ||---|---:|---:|
|
symbol != "s0"| 0 ❌ | 4 ✅ ||
(symbol != "s0") \| (symbol == "s0")| 0 ❌ | 5 ✅ ||
(symbol != "s0") & (region == "b")| 0 ❌ | 3 ✅ ||
symbol.is_in([...])(positive control) | 4 ✅ | 4 ✅ |Root cause: the DNF partition enumerator conflated two empty results — a genuine contradiction and a non-enumerable constraint — into an empty
expected_parts_df, which the read plan turned intouse_paths=[](read nothing)._get_column_values_from_constraintsnow returnsNonefor non-enumerable (vs empty for contradiction), and_process_dnf_clause_to_partitionsmaps that to the existing{None}unconstrained placeholder, so the read globs and applies the full predicate. Scoped todate_column is None— date-partitioned caches keep their prior behavior.The write bug (worse; also fixed)
A wildcard (unconstrained) write target couldn't be narrowed to concrete partitions, so the previous code either wrote the whole upstream, rewriting existing partition files (a CACHE-mode violation — reproducible even with an ordinary non-partition predicate like
filter(v > 2), which could replace good cached data if upstream changed), or dropped the wildcard and under-wrote on incomplete caches. Now, for adate_column is Nonewildcard target:restrict_expr_to_columns(predicate, join_cols) AND not_existing— covers missing partitions, never rewrites existing.s0for asymbol != "s0"query) untouched.Also
"expanded paths were empty"."null"directory that doesn't round-trip on read). Per maintainer direction, documented rather than guarded.Tests
New tests for negative/unbounded/OR/partial-wildcard reads (populated and incomplete caches), the no-rewrite invariant (mtime + mutated-upstream), REBUILD out-of-scope preservation, the empty-result case, and date-column behavior preservation. Full suite: 1637 passed.
Reviewed
Iteratively reviewed (Sol) — caught and fixed: the shared
expected_parts_dfwrite-path interaction, a REBUILD out-of-scope overwrite, a date-partitioned regression from the read re-classification (fixed by scoping todate_column is None), and an empty-glob error. Final approach avoidsscan_parquet(schema=...)forpolars>=1.8compatibility.Out of scope (pre-existing, confirmed on
main, gated to thedate_column-present path)These are documented as known limitations; fixing them requires date-granularity-aware partition exclusion and is left for a follow-up.