stevomitric opened a new pull request, #58577:
URL: https://github.com/apache/spark/pull/58577

   ### What changes were proposed in this pull request?
   
   `months_between` now accepts nanosecond-precision timestamps — 
`TIMESTAMP_LTZ(p)` / `TIMESTAMP_NTZ(p)`, `p ∈ [7, 9]` — alongside the 
microsecond types. Each nanosecond operand is reduced to its `epochMicros` 
before the month count is computed, mirroring `SubtractTimestamps`. 
`TimestampType` (not `AnyTimestampType`) is kept in `inputTypes` so microsecond 
behavior is unchanged, and the eval/codegen zone switches to 
`zoneIdForType(date1.dataType)` — a no-op for LTZ-micros, UTC for NTZ. The 
result stays `DoubleType` on the microsecond grid, so the dropped 
sub-microsecond digits don't affect it.
   
   ### Why are the changes needed?
   
   `months_between` previously failed analysis on nanosecond timestamps. This 
fills that gap under the SPARK-56822 umbrella.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `months_between` previously rejected nanosecond-precision timestamps 
with an input-type mismatch; it now accepts them and returns the `DOUBLE` month 
count. Microsecond-timestamp behavior is unchanged. (Change within the 
unreleased nanos work.)
   
   ### How was this patch tested?
   
   Added `SPARK-57819: months_between over nanosecond-precision timestamps` to 
`DateExpressionsSuite`, covering both families at precisions 7/8/9, both 
`roundOff` settings, nulls, and the NTZ→UTC path, asserting the nanosecond 
result equals the microsecond expectation. `DateExpressionsSuite` passes 
(96/96, existing tests unchanged); scalastyle clean; JDK 17.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to