MaxGekk opened a new pull request #31832:
URL: https://github.com/apache/spark/pull/31832


   ### What changes were proposed in this pull request?
   Support `timestamp +/- year-month interval`. In the PR, I propose to 
introduce new binary expression `TimestampAddYMInterval` similarly to 
`DateAddYMInterval`. It invokes new method `timestampAddMonths` from 
`DateTimeUtils` by passing a timestamp as an offset in microseconds since the 
epoch, amount of months from the giveb year-month interval, and the time zone 
ID in which the operation is performed. The `timestampAddMonths()` method 
converts the input microseconds to a local timestamp, adds months to it, and 
converts the results back to an instant in microseconds at the given time zone.
   
   ### Why are the changes needed?
   To conform the ANSI SQL standard which requires to support such operation 
over timestamps and intervals:
   <img width="811" alt="Screenshot 2021-03-12 at 11 36 14" 
src="https://user-images.githubusercontent.com/1580697/110914390-5f412480-8327-11eb-9f8b-e92e73c0b9cd.png";>
   
   
   ### Does this PR introduce _any_ user-facing change?
   Should not since new intervals have not been released yet.
   
   ### How was this patch tested?
   By running new tests:
   ```
   $ build/sbt "test:testOnly *DateTimeUtilsSuite"
   $ build/sbt "test:testOnly *DateExpressionsSuite"
   $ build/sbt "test:testOnly *ColumnExpressionSuite"
   ```


----------------------------------------------------------------
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.

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