You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "Huang-404-Q (via GitHub)" <gi...@apache.org> on 2026/10/21 04:24:37 UTC
[PR] [SPARK-60333][SQL] Fix make_timestamp second overflow [spark]
Huang-404-Q opened a new pull request, #59664:
URL: https://github.com/apache/spark/pull/59664
### What changes were proposed in this pull request?
`DateTimeExpressionUtils.makeTimestampMicros` narrows the unscaled micros of `secAndMicros` (a `Decimal(16, 6)`) to `int` before the range check. The unscaled value can exceed `Int`, so it wraps modulo 2^32 and a wrapped value can look like a valid second.
Compute in `long` and validate the seconds before narrowing. The `seconds == 60` PostgreSQL compatibility case and the `60.5` fraction error are unchanged.
### Why are the changes needed?
`make_timestamp_ntz(2020, 1, 1, 0, 0, 4324.967296)` returns `2020-01-01 00:00:30` instead of `NULL` (non-ANSI) or `DATETIME_FIELD_OUT_OF_BOUNDS` (ANSI). `-2147483648` wraps to 0. This affects `make_timestamp`, `make_timestamp_ltz`, `make_timestamp_ntz` and the `try_` variants, in both interpreted and codegen paths.
### Does this PR introduce _any_ user-facing change?
Yes: out-of-range second values now fail instead of silently wrapping.
### How was this patch tested?
Added cases to `DateExpressionsSuite` "creating values of Timestamp/TimestampNTZ via make_timestamp" for `4324.967296` and `-2147483648`.
I could not run the suite locally (no sbt/maven on this machine); the arithmetic was verified with a standalone Java reproduction. CI should run `DateExpressionsSuite`.
### Was this patch authored or co-authored using generative AI tooling?
Yes, with Claude Code. A human reviewed the diff and takes responsibility.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60333][SQL] Fix make_timestamp second overflow [spark]
Posted by "Huang-404-Q (via GitHub) via reviews" <re...@spark.apache.org>.
Huang-404-Q closed pull request #59664: [SPARK-60333][SQL] Fix make_timestamp second overflow
URL: https://github.com/apache/spark/pull/59664
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60333][SQL] Fix make_timestamp second overflow [spark]
Posted by "Huang-404-Q (via GitHub) via reviews" <re...@spark.apache.org>.
Huang-404-Q commented on PR #59664:
URL: https://github.com/apache/spark/pull/59664#issuecomment-7213553499
Closing as superseded by SPARK-60743 (`dbea6d2f` on `master`, discussed in #59955). The shared seconds validation prevents the same overflow and includes regression coverage for ANSI and non-ANSI behavior; this PR no longer needs a rebase.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org