[ 
https://issues.apache.org/jira/browse/SPARK-30857?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

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

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

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

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


> Wrong truncations of timestamps before the epoch to hours and days
> ------------------------------------------------------------------
>
>                 Key: SPARK-30857
>                 URL: https://issues.apache.org/jira/browse/SPARK-30857
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.4.5
>            Reporter: Maxim Gekk
>            Priority: Major
>
> Truncations to seconds and minutes of timestamps after the epoch are correct:
> {code:sql}
> spark-sql> select date_trunc('HOUR', '2020-02-11 00:01:02.123'), 
> date_trunc('HOUR', '2020-02-11 00:01:02.789');
> 2020-02-11 00:00:00   2020-02-11 00:00:00
> {code}
> but truncations of timestamps before the epoch are incorrect:
> {code:sql}
> spark-sql> select date_trunc('HOUR', '1960-02-11 00:01:02.123'), 
> date_trunc('HOUR', '1960-02-11 00:01:02.789');
> 1960-02-11 01:00:00   1960-02-11 01:00:00
> {code}
> The result must be *1960-02-11 00:00:00 1960-02-11 00:00:00*
> The same for the DAY level:
> {code:sql}
> spark-sql> select date_trunc('DAY', '1960-02-11 00:01:02.123'), 
> date_trunc('DAY', '1960-02-11 00:01:02.789');
> 1960-02-12 00:00:00   1960-02-12 00:00:00
> {code}
> The result must be *1960-02-11 00:00:00 1960-02-11 00:00: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