Share one partition-exclusion predicate across the caches #64
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 524 lines diff across 6 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.375
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #64"
general
weight: 0.35
timkpaine
Summary
The column (
cache), in-memory (cache_memory), and Parquet (cache_parquet) caches each built their own predicate to restrict a query to the not-yet-cached partitions — "exclude every known partition", i.e.~OR(AND(col == value)). The three implementations had diverged in behavior:| cache | null handling | is_in compression | contradiction-analyzable |
|---|---|---|---|
|
cache(_extract_filter_from_df) |ne— not null-safe | ✅ (_repeated_grouping) | ✅ ||
cache_memory(_exclude_built) |eq_missing— null-safe | ❌ | n/a (never used) ||
cache_parquet(_build_not_existing_partitions_pred) |==— not null-safe | ❌ | — |This consolidates all three into a single builder,
util.partition_exclusion_predicate, with one consistent behavior:eq_missing/ a null-awarenot in), so a null partition value excludes exactly its own rows.fill_null, which is opaque to the analyzer and would defeat the "skip an impossible query" optimization. Uses onlyis_in/is_null/ne_missing, which the analyzer already understands (EQ_VALIDITY/NOT_EQ_VALIDITY/in/is).is_in+ repeated grouping keep the expression small even with many partitions.lazy_cache,lazy_cache_memory, andlazy_cache_parquetnow all delegate to it.Behavior change: unfiltered reads restrict the discovery query
cache()now excludes already-cached partitions even when there is no incoming predicate. Previously an unfiltered read over a fully-cached partitioned frame re-scanned the whole source; now it excludes the known partitions (mirroringcache_memory's build planner). The contradiction check is skipped when there is no incoming predicate (a bare exclusion is never a contradiction, and the check can be non-trivial).Null-safety fixes surfaced by the consolidation
1.
cache()fixed-partition scan (== p_val→eq_missing): fetching additional columns for a known null-valued partition returned no rows (col == Noneis null), producing mismatched column heights. This was previously masked by the full re-scan the new exclusion avoids. (Found in review.)2.
cache_memory()carrier frame (infer_schema_length=None): a partition column that is null in the first keys but valued later inferredNulland failed to append the later value. (Found in review.)Validation
eq_missing, single/multi-column, contradiction-analyzability, dedup) + regression tests for both null-safety fixes and the unfiltered-exclusion behavior.- The shared builder is not a bottleneck: exclusion build 0.016s and contradiction detection 0.026s at 50k partitions; expression stays compressed.
- This PR introduces no perf regression: full-reread 1.281s (this branch) vs 1.310s (
main), identical.- Independently confirmed on
main: the pre-existingcache()cost at very high partition counts is the per-call cache-key traversal + block reassembly (already noted in a code comment), not the exclusion predicate — untouched here.Out of scope (pre-existing, confirmed on
main)The stress test also surfaced pre-existing
cache_parquetread-plan limitations (acol.is_null()or negativecol != x/ all-but-one filter over finite partitions can enumerate no paths and return 0 rows). These reproduce identically onmain, live in the read-plan/partition-enumeration path (not the write-plan helper changed here), and are not addressed in this PR.Relation to #63
Independent of #63 (
column_granularity); both branch frommainand touch different regions ofcache(), so they merge cleanly in either order.