Repository navigation
fix: preserve fractional seconds in 'second' and 'millisecond' - #22504
aguilaredu wants to merge 2 commits into
Conversation
80d035a to
e688270
Compare
cc @Dandandan |
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
| if is_epoch(part) { | ||
| if is_epoch(part) || is_fractional_second(part) { | ||
| Field::new(self.name(), DataType::Float64, nullable) | ||
| } else if is_nanosecond(part) { | ||
| // See notes on [seconds_ns] for rationale | ||
| Field::new(self.name(), DataType::Int64, nullable) | ||
| } else { | ||
| Field::new(self.name(), DataType::Int32, nullable) |
There was a problem hiding this comment.
I'd be in favor of dropping the conditional completely, and always returning float64, following Postgres semantics
comphead
left a comment
There was a problem hiding this comment.
Thanks @aguilaredu for the PR, I'm currently checking https://spark.apache.org/docs/latest/api/sql/#datepart
The second is finest fraction you can extract from the timestamp
|
Hey, I opened up a PR making date_part postgres compliant here #22851, lmk if thats okay. Thanks! |
|
Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days. |
Which issue does this PR close?
extract(second ...)should preserve fractional seconds #22266extract(milliseconds ...)should preserve fractional milliseconds #22256Rationale for this change
The change will achieve PostgreSQL-compatible semantics. More discussion can be found on #22266
What changes are included in this PR?
EXTRACT(SECOND)andEXTRACT(MILLISECOND)now returnf64instead ofi32to preserve fractionals.secondsmethod calculation formula to prevent floating-point precision errors.date_partnow delegates its return type to DataFusion's implementation rather than hardcodingi32.f64return types and added new tests to the Spark suite forEXTRACT(MILLISECOND).Are these changes tested?
Yes. Existing tests were updated to assert
f64returns, and new tests were added to the Spark suite specifically forEXTRACT(MILLISECOND)Are there any user-facing changes?
Yes, the return type of
EXTRACT(SECONDS)andEXTRACT(MILLISECONDS)is nowf64instead ofi32.