Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-12191 Hive timestamp problems
  3. HIVE-12192

Hive should carry out timestamp computations in UTC

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • None
    • 3.1.0
    • Hive

    Description

      Hive currently uses the "local" time of a java.sql.Timestamp to represent the SQL data type TIMESTAMP WITHOUT TIME ZONE. The purpose is to be able to use Timestamp#getYear() and similar methods to implement SQL functions like year.

      When the SQL session's time zone is a DST zone, such as America/Los_Angeles that alternates between PST and PDT, there are times that cannot be represented because the effective zone skips them.

      hive> select TIMESTAMP '2015-03-08 02:10:00.101';
      2015-03-08 03:10:00.101
      

      Using UTC instead of the SQL session time zone as the underlying zone for a java.sql.Timestamp avoids this bug, while still returning correct values for getYear etc. Using UTC as the convenience representation (timestamp without time zone has no real zone) would make timestamp calculations more consistent and avoid similar problems in the future.

      Notably, this would break the unix_timestamp UDF that specifies the result is with respect to "the default timezone and default locale". That function would need to be updated to use the System.getProperty("user.timezone") zone.

      Attachments

        1. HIVE-12192.28.patch
          4.14 MB
          jcamachorodriguez
        2. HIVE-12192.27.patch
          4.14 MB
          jcamachorodriguez
        3. HIVE-12192.26.patch
          4.11 MB
          jcamachorodriguez
        4. HIVE-12192.25.patch
          4.09 MB
          jcamachorodriguez
        5. HIVE-12192.24.patch
          4.09 MB
          jcamachorodriguez
        6. HIVE-12192.23.patch
          4.09 MB
          jcamachorodriguez
        7. HIVE-12192.22.patch
          4.09 MB
          jcamachorodriguez
        8. HIVE-12192.21.patch
          4.09 MB
          jcamachorodriguez
        9. HIVE-12192.20.patch
          4.09 MB
          jcamachorodriguez
        10. HIVE-12192.19.patch
          4.09 MB
          jcamachorodriguez
        11. HIVE-12192.18.patch
          4.09 MB
          jcamachorodriguez
        12. HIVE-12192.17.patch
          4.09 MB
          jcamachorodriguez
        13. HIVE-12192.16.patch
          3.97 MB
          jcamachorodriguez
        14. HIVE-12192.15.patch
          3.97 MB
          jcamachorodriguez
        15. HIVE-12192.14.patch
          3.97 MB
          jcamachorodriguez
        16. HIVE-12192.13.patch
          3.97 MB
          jcamachorodriguez
        17. HIVE-12192.12.patch
          3.97 MB
          jcamachorodriguez
        18. HIVE-12192.11.patch
          3.97 MB
          jcamachorodriguez
        19. HIVE-12192.10.patch
          3.92 MB
          jcamachorodriguez
        20. HIVE-12192.09.patch
          3.92 MB
          jcamachorodriguez
        21. HIVE-12192.08.patch
          3.65 MB
          jcamachorodriguez
        22. HIVE-12192.07.patch
          3.65 MB
          jcamachorodriguez
        23. HIVE-12192.06.patch
          1.88 MB
          jcamachorodriguez
        24. HIVE-12192.05.patch
          1.87 MB
          jcamachorodriguez
        25. HIVE-12192.04.patch
          1.19 MB
          jcamachorodriguez
        26. HIVE-12192.03.patch
          1.98 MB
          jcamachorodriguez
        27. HIVE-12192.02.patch
          514 kB
          jcamachorodriguez
        28. HIVE-12192.01.patch
          463 kB
          jcamachorodriguez
        29. HIVE-12192.patch
          320 kB
          jcamachorodriguez

        Issue Links

          Activity

            People

              jcamacho Jesús Camacho Rodríguez
              rdblue Ryan Blue
              Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: