← Back to Pull requests

Fix cache_parquet non-enumerable predicate reads and wildcard writes #65

Closed
unknown closed this pull request without merging on Oct 01, 2026 16:53 UTC
View on GitHub
unknown unknown commented on Sep 27, 2026 22:44 UTC
Author

Summary

Fixes a family of cache_parquet correctness bugs (all reproduced on main) 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 into use_paths=[] (read nothing). _get_column_values_from_constraints now returns None for non-enumerable (vs empty for contradiction), and _process_dnf_clause_to_partitions maps that to the existing {None} unconstrained placeholder, so the read globs and applies the full predicate. Scoped to date_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 a date_column is None wildcard target:
  • CACHE writes upstream filtered by restrict_expr_to_columns(predicate, join_cols) AND not_existing — covers missing partitions, never rewrites existing.

  • REBUILD writes only the restricted predicate — refreshes in-scope partitions, leaves out-of-scope files (e.g. s0 for a symbol != "s0" query) untouched.
  • Also


  • A wildcard read matching no cached files now returns an empty frame instead of raising "expanded paths were empty".

  • Null values in partition columns documented as unsupported (they write to a "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_df write-path interaction, a REBUILD out-of-scope overwrite, a date-partitioned regression from the read re-classification (fixed by scoping to date_column is None), and an empty-glob error. Final approach avoids scan_parquet(schema=...) for polars>=1.8 compatibility.

    Out of scope (pre-existing, confirmed on main, gated to the date_column-present path)


  • The exclude-existing predicate isn't date-partition-granularity aware: monthly/yearly caches can compare a widened key against raw dates.

  • A mixed finite+wildcard clause under a date predicate can omit partitions.
  • These are documented as known limitations; fixing them requires date-granularity-aware partition exclusion and is left for a follow-up.

    Diff: 457 lines (+342 / -115) across 5 files Reviewer: timkpaine Review duration: 5409m
    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
    0.46
    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%
    60%
    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.367
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #65"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 45.5% (MEDIUM) · Higher = larger blast radius
    45.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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 18.0% · Safe to merge
    18.0%