← Back to Pull requests

fix: check Parquet TIMESTAMP_MILLIS overflow in nested Arrow dictionaries #7715

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 20, 2026 22:10 UTC
Author

Which issue does this PR close?

Partially addresses #5553. This extends #5740 to nested Arrow dictionary leaves in native V1 Parquet scans without data filters. #5739 and #7731 concern scans with data filters.

The reviewer also reported a pre-existing panic on a valid top-level dictionary timestamp of 7 ms. Its schema adapter and downcast are on a separate code path. Flat-column report · Tracking issue #7747

Rationale for this change

When a Parquet footer's ARROW:schema declares a dictionary of millisecond timestamps, arrow-rs reconstructs a DictionaryArray on read. This is independent of the Parquet page encoding exercised by the existing overflow tests. Arrow schema restoration, primitive reader

For an unfiltered SELECT s.ts FROM t, the dictionary wrapper bypasses Comet's checked multiplication in the struct converter. A referenced value of 9223372036854776 milliseconds overflows when multiplied by 1,000. Comet returns NULL through Arrow's safe cast. Spark raises ArithmeticException("long overflow"). Arrow timestamp cast, Spark Parquet reader

With the default settings, Spark reads 4,096 rows at a time and Comet can read 8,192. Put a valid timestamp in row 1 and the first overflow in row 4,097 of the same row group. Spark can finish LIMIT 1 after its first batch. Reading the whole table reaches row 4,097 and raises the arithmetic exception. The checked conversion has to respect that boundary.

What changes are included in this PR?

Struct, list, and map projections already use the recursive Parquet converter. It now looks through dictionary types when deciding which children need ancestor validity. At a dictionary timestamp leaf, it first tries checked conversion on the dictionary values. If all entries fit, it gathers microseconds by key directly into the output. For N elements referencing D entries, the temporary timestamp buffer holds D values.

If an entry overflows, the converter gathers milliseconds in row order and applies the existing checked conversion with ancestor validity and slice bounds. An overflow raises ParquetTimestampOverflow only when a visible element references it.

The V1 scan opts into this check by recording Spark's Parquet reader size when constructing the RDD. The opt-in requires an empty list of Spark data filters. Readers such as Delta can apply deletion vectors before forming a batch, so their surviving row count can differ from the number Spark decodes.

If the configured sizes differ, the scan checks the footer for a projected nested dictionary timestamp that needs conversion. If the row-group bounds establish that all millisecond timestamps fit, Comet reads at its usual size. Otherwise, for a matching file it reuses the footer to plan decoding in batches that divide both configured sizes. It validates a full Spark batch within each row group before yielding its first piece. A residual native filter streaming from an eligible scan emits matches as they arrive so a limit can stop there.

At the default sizes the affected decoder reads 4,096 rows per batch. With relatively prime custom sizes the decoder can read one row at a time and hold multiple batches until it has checked a Spark batch. That cost applies when the file contains a requested dictionary timestamp and its bounds allow overflow or are missing. The filter adjustment also applies to plain nested timestamp scans because it runs before the footer is available.

How are these changes tested?

The Spark SQL regression writes a three-row Parquet file with a nested dictionary timestamp and an overflow in row 3. With Spark's batch size set to 2 and Comet's to 3, it checks LIMIT 1, a residual filter followed by LIMIT 1, RDD.take(1), and the arithmetic exception on a full read. Reversing the sizes puts the overflow in Spark's first batch, so even LIMIT 1 must raise.

A native regression writes and reads a Parquet struct with a dictionary timestamp child. It verifies that repeated keys and a null produce [7000, NULL, 7000] microseconds, then adds a row referencing an overflowing entry. With checking enabled, reading all four rows raises ParquetTimestampOverflow. With checked_timestamp_overflow = false, the setting used for scans with data filters, the same four rows produce [7000, NULL, 7000, NULL].

The container tests exercise both overflow signs in structs, lists, and maps, including null ancestors, slices, and required children. A leaf test exercises both conversion paths with repeated keys, a null key, a null dictionary value, an unused entry, and a requested timezone.

Diff: 650 lines (+487 / -163) across 8 files Reviewer: andygrove Review duration: 14047m
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
0.52
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
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.388
Shallow Review Depth shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7715"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% 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: 52% (MEDIUM) · Higher = larger blast radius
52%
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: 46.7% · Lower = rushed or shallow review
46.7%
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: 27.7% · Safe to merge
27.7%