Maxim Gekk created SPARK-30793:
----------------------------------

             Summary: Wrong truncations of timestamps before the epoch to 
minutes and seconds
                 Key: SPARK-30793
                 URL: https://issues.apache.org/jira/browse/SPARK-30793
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.0.0
            Reporter: Maxim Gekk


Truncations to seconds and minutes of timestamps after the epoch are correct:
{code:sql}
spark-sql> select date_trunc('SECOND', '2020-02-11 00:01:02.123'), 
date_trunc('SECOND', '2020-02-11 00:01:02.789');
2020-02-11 00:01:02     2020-02-11 00:01:02
{code}
but truncations of timestamps before the epoch are incorrect:
{code:sql}
spark-sql> select date_trunc('SECOND', '1960-02-11 00:01:02.123'), 
date_trunc('SECOND', '1960-02-11 00:01:02.789');
1960-02-11 00:01:03     1960-02-11 00:01:03
{code}
The result must be *1960-02-11 00:01:02 1960-02-11 00:01:02*

The same for the MINUTE level:
{code:sql}
spark-sql> select date_trunc('MINUTE', '1960-02-11 00:01:01'), 
date_trunc('MINUTE', '1960-02-11 00:01:50');
1960-02-11 00:02:00     1960-02-11 00:02:00
{code}
The result must be 1960-02-11 00:01:00  1960-02-11 00:01:00



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to