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

   ### What changes were proposed in this pull request?
   
   Extend the `sequence(start, stop, step)` function to accept 
nanosecond-precision timestamp endpoints (`TIMESTAMP_LTZ(p)` / 
`TIMESTAMP_NTZ(p)`, p in 7..9), producing an array of the same nanosecond type.
   
   A nanosecond value is carried as a `TimestampNanosVal` object rather than a 
primitive `long`, so the existing primitive-array sequence machinery cannot 
hold it directly. Instead the microsecond sequence logic is reused on 
`epochMicros` (keeping all of the existing DST, month, overflow and length 
handling) and each generated element is re-wrapped as 
`TimestampNanosVal.fromParts(micros, startFraction)`, materialized through 
`GenericArrayData`. Membership is decided on the microsecond grid (every step 
is microsecond-granular) and each element keeps the start value's 
sub-microsecond fraction.
   
   The `SEQUENCE_WRONG_INPUT_TYPES` error message now lists the nanosecond 
timestamp types among the accepted start/stop types.
   
   ### Why are the changes needed?
   
   Part of the nanosecond-precision timestamp umbrella (SPARK-56822). Without 
this, `sequence` rejected nanosecond timestamp endpoints even though the 
microsecond timestamp types were supported.
   
   ### Does this PR introduce any user-facing change?
   
   Yes. `sequence` now accepts nanosecond-precision timestamp start/stop values 
and returns an array of that type.
   
   ### How was this patch tested?
   
   New unit test in `CollectionExpressionsSuite` (LTZ and NTZ, precisions 
7/8/9, day-time and default and negative and single-element and null cases; 
interpreted and codegen) and updated `SEQUENCE_WRONG_INPUT_TYPES` assertions in 
`DataFrameFunctionsSuite`.
   
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Co-authored-by: Claude 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