fix: check Parquet TIMESTAMP_MILLIS overflow in nested Arrow dictionaries #7715
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7715"
general
weight: 0.35
andygrove
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:schemadeclares a dictionary of millisecond timestamps, arrow-rs reconstructs aDictionaryArrayon read. This is independent of the Parquet page encoding exercised by the existing overflow tests. Arrow schema restoration, primitive readerFor an unfiltered
SELECT s.ts FROM t, the dictionary wrapper bypasses Comet's checked multiplication in the struct converter. A referenced value of9223372036854776milliseconds overflows when multiplied by 1,000. Comet returnsNULLthrough Arrow's safe cast. Spark raisesArithmeticException("long overflow"). Arrow timestamp cast, Spark Parquet readerWith 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 1after 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
Nelements referencingDentries, the temporary timestamp buffer holdsDvalues.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
ParquetTimestampOverflowonly 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 byLIMIT 1,RDD.take(1), and the arithmetic exception on a full read. Reversing the sizes puts the overflow in Spark's first batch, so evenLIMIT 1must 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 raisesParquetTimestampOverflow. Withchecked_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.