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

Wrong truncations of timestamps before the epoch to minutes and seconds

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0, 2.3.4, 2.4.5, 3.0.0
    • Fix Version/s: 2.4.6, 3.0.0
    • Component/s: SQL
    • Labels:

      Description

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

      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
      

      but truncations of timestamps before the epoch are incorrect:

      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
      

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

      The same for the MINUTE level:

      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
      

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                maxgekk Maxim Gekk
                Reporter:
                maxgekk Maxim Gekk
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: