[SPARK-56804][SQL] Add bulk read+convert path for DATE to TimestampNTZ Parquet vector updater#55971
Closed
LuciferYang wants to merge 4 commits into
Closed
[SPARK-56804][SQL] Add bulk read+convert path for DATE to TimestampNTZ Parquet vector updater#55971LuciferYang wants to merge 4 commits into
LuciferYang wants to merge 4 commits into
Conversation
…Z Parquet vector updater
…to-tsntz # Conflicts: # sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetIOSuite.scala
Contributor
Author
LuciferYang
added a commit
that referenced
this pull request
May 19, 2026
…Z Parquet vector updater ### What changes were proposed in this pull request? Extend the bulk-read pattern (SPARK-56791 / 56801 / 56802 / 56803) to `DateToTimestampNTZUpdater`. Add a `readIntegersAsTimestampMicros` default method on `VectorizedValuesReader`, override it in `VectorizedPlainValuesReader` to fetch source bytes once via `getBuffer(total * 4)` and run a tight conversion loop, and reduce `DateToTimestampNTZUpdater.readValues` to a one-line delegation. Scope: UTC, `CORRECTED` rebase mode; the `LEGACY` / `EXCEPTION` rebase variants (handled by `DateToTimestampNTZWithRebaseUpdater`) are out of scope. ### Why are the changes needed? This was first proposed in #55855 and closed because benchmarks showed no measurable gain -- the per-row work was dominated by `DateTimeUtils.daysToMicros`'s `LocalDate` / `ZonedDateTime` / `Instant` allocation chain, swamping the savings from collapsing N `getBuffer(4)` slice allocations. SPARK-56874 fixed that by fast-pathing `daysToMicros` at `ZoneOffset.UTC` to `Math.multiplyExact(days.toLong, MICROS_PER_DAY)`. With the conversion now cheap, the bulk-read savings become visible: | JDK | Master baseline | With this PR | Speedup | |---|---|---|---| | 17 | 2.8 ns/row (357.5 M/s) | 1.7 ns/row (605.2 M/s) | ~1.7x | | 21 | 2.7 ns/row (366.1 M/s) | 1.1 ns/row (934.8 M/s) | ~2.5x | | 25 | 2.6 ns/row (378.3 M/s) | 1.1 ns/row (884.9 M/s) | ~2.4x | ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? New unit tests in `ParquetVectorUpdaterSuite` for `readIntegersAsTimestampMicros` (various batch sizes, single-value `readValue`, UTC conversion semantics). New integration test in `ParquetIOSuite` for INT32 DATE -> `TimestampNTZType` through the vectorized reader with both dictionary-encoded and plain pages. Benchmark numbers above are from GHA. ### Was this patch authored or co-authored using generative AI tooling? No Closes #55971 from LuciferYang/SPARK-56804-date-to-tsntz. Authored-by: YangJie <yangjie01@baidu.com> Signed-off-by: yangjie01 <yangjie01@baidu.com> (cherry picked from commit 19073d8) Signed-off-by: yangjie01 <yangjie01@baidu.com>
Contributor
Author
|
Merged into master and branch-4.3. Thanks @yaooqinn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Extend the bulk-read pattern (SPARK-56791 / 56801 / 56802 / 56803) to
DateToTimestampNTZUpdater. Add areadIntegersAsTimestampMicrosdefault method onVectorizedValuesReader, override it inVectorizedPlainValuesReaderto fetch source bytes once viagetBuffer(total * 4)and run a tight conversion loop, and reduceDateToTimestampNTZUpdater.readValuesto a one-line delegation. Scope: UTC,CORRECTEDrebase mode; theLEGACY/EXCEPTIONrebase variants (handled byDateToTimestampNTZWithRebaseUpdater) are out of scope.Why are the changes needed?
This was first proposed in #55855 and closed because benchmarks showed no measurable gain -- the per-row work was dominated by
DateTimeUtils.daysToMicros'sLocalDate/ZonedDateTime/Instantallocation chain, swamping the savings from collapsing NgetBuffer(4)slice allocations.SPARK-56874 fixed that by fast-pathing
daysToMicrosatZoneOffset.UTCtoMath.multiplyExact(days.toLong, MICROS_PER_DAY). With the conversion now cheap, the bulk-read savings become visible:Does this PR introduce any user-facing change?
No.
How was this patch tested?
New unit tests in
ParquetVectorUpdaterSuiteforreadIntegersAsTimestampMicros(various batch sizes, single-valuereadValue, UTC conversion semantics). New integration test inParquetIOSuitefor INT32 DATE ->TimestampNTZTypethrough the vectorized reader with both dictionary-encoded and plain pages. Benchmark numbers above are from GHA.Was this patch authored or co-authored using generative AI tooling?
No