Use non-null value counts for Parquet dictionary caches #12122
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
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.328
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #12122"
general
weight: 0.35
JonSnow1807
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.