Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-30857

Wrong truncations of timestamps before the epoch to hours and days

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.3.0, 2.3.4, 2.4.5
    • 2.4.6
    • SQL

    Description

      Truncations to seconds and minutes of timestamps after the epoch are correct:

      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
      

      but truncations of timestamps before the epoch are incorrect:

      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
      

      The result must be 1960-02-11 00:00:00 1960-02-11 00:00:00

      The same for the DAY level:

      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
      

      The result must be 1960-02-11 00:00:00 1960-02-11 00:00:00

      Attachments

        Issue Links

          Activity

            People

              maxgekk Max Gekk
              maxgekk Max Gekk
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: