You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/17 23:03:23 UTC

[GitHub] [spark] bersprockets opened a new pull request, #37559: [SPARK-37544][SQL][3.1] Correct date arithmetic in sequences

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

   Backport of #36546
   
   ### What changes were proposed in this pull request?
   
   Change `TemporalSequenceImpl` to pass a time-zone aware value to `DateTimeUtils#timestampAddInterval`, rather than a time-zone agnostic value, when performing `Date` arithmetic.
   
   ### Why are the changes needed?
   
   The following query gets the wrong answer if run in the America/Los_Angeles time zone:
   ```
   spark-sql> select sequence(date '2021-01-01', date '2022-01-01', interval '3' month) x;
   [2021-01-01,2021-03-31,2021-06-30,2021-09-30,2022-01-01]
   Time taken: 0.664 seconds, Fetched 1 row(s)
   spark-sql>
   ```
   The answer should be
   ```
   [2021-01-01,2021-04-01,2021-07-01,2021-10-01,2022-01-01]
   ```
   `TemporalSequenceImpl` converts the date to micros by multiplying days by micros per day. This converts the date into a time-zone agnostic timestamp. However, `TemporalSequenceImpl` uses `DateTimeUtils#timestampAddInterval` to perform the arithmetic, and that function assumes a _time-zone aware_ timestamp.
   
   This PR converts the date to a time-zone aware value before calling `DateTimeUtils#timestampAddInterval`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   New unit test.


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


[GitHub] [spark] dongjoon-hyun commented on pull request #37559: [SPARK-37544][SQL][3.1] Correct date arithmetic in sequences

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #37559:
URL: https://github.com/apache/spark/pull/37559#issuecomment-1219906170

   Thank you, @bersprockets and @HyukjinKwon .
   Merged to branch-3.1.


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


[GitHub] [spark] dongjoon-hyun closed pull request #37559: [SPARK-37544][SQL][3.1] Correct date arithmetic in sequences

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun closed pull request #37559: [SPARK-37544][SQL][3.1] Correct date arithmetic in sequences
URL: https://github.com/apache/spark/pull/37559


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