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

Add the TIMESTAMPDIFF() function

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.3.0
    • 3.3.0
    • SQL
    • None

    Description

      Two functions that are part of the ODBC api and implemented virtually by ALL other databases are missing in Spark SQL.

      TIMESTAMPADD() and TIMESTAMPDIFF()

      See

      The TIMESTAMPDIFF() function is also VERY convenient and would be a great addition because getting the difference between two timestamps in seconds in spark today requires converting to unixtimestamp and back.

      SELECT TIMESTAMPDIFF(SECOND, '2021-12-30 01:02:00':timestamp,  '2021-12-30 01:00:00':timestamp)
      >120
      -- Current Support
      SELECT unix_timestamp('2021-12-30 01:00:00':timestamp) - unix_timestamp('2021-12-30 01:00:00':timestamp)
      > 120
      

      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: