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

Wrong truncations of timestamps before the epoch to minutes and seconds

    XMLWordPrintableJSON

Details

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

    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

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

              Dates

                Created:
                Updated:
                Resolved: