← Back to Pull requests

Use non-null value counts for Parquet dictionary caches #12122

Closed
unknown closed this pull request without merging on Nov 12, 2026 20:19 UTC
View on GitHub
unknown unknown commented on Nov 08, 2026 08:10 UTC
Author

Which issue does this PR close?

Closes #12115.

Rationale for this change

The Parquet Arrow writer counts all rows when deciding whether to create a dictionary cache, even though only selected non-null values are encoded. This can allocate a cache for a batch containing mostly or entirely null values.

Nulls can come from dictionary keys, dictionary values, or a parent array masking a child value.

What changes are included in this PR?

Pass the complete selection’s non-null value count through the internal write_gather interface and use it for the dictionary-cache decision.

The count covers the enclosing write batch, preserving profitable caching when the writer splits it into smaller mini-batches. Existing caches remain available for reuse across sparse and all-null writes.

Are these changes tested?

Regression tests cover sliced inputs, null keys, null dictionary values, parent-masked values, and partially or entirely null selections. A dense control checks that mini-batching does not disable a profitable cache. The memory regression fails against the original implementation and passes with this change.

Retained ArrowWriter::memory_size() bytes after one write to a fresh writer:

| Rows | Dictionary values | Input | Before | After |
|---:|---:|---|---:|---:|
| 8,192 | 4,096 | Dense | 372,778 | 372,778 |
| 8,192 | 4,096 | 50% null | 340,010 | 340,010 |
| 8,192 | 4,096 | Approximately 99% null | 38,890 | 6,122 |
| 8,192 | 4,096 | All null | 32,768 | 0 |
| 131,072 | 65,536 | Approximately 99% null | 620,983 | 96,695 |
| 131,072 | 65,536 | All null | 524,456 | 168 |

The affected cases avoid 32 KiB or 512 KiB of new cache storage, and the large 99%-null and all-null writes were about 10% and 52% faster, with the dense control about 2% slower.

Are there any user-facing changes?

No.

AI assistance was used for implementation, regression tests, independent review, and validation.

Diff: 241 lines (+180 / -61) across 3 files Reviewer: JonSnow1807 Review duration: 6489m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 241 lines diff across 3 files
0.39
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.328
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #12122"
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: 38.8% (MEDIUM) · Higher = larger blast radius
38.8%
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: 15.3% · Safe to merge
15.3%