Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-10178

DateWritable incorrectly calculates daysSinceEpoch for negative Unix time

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.12.0, 0.13.0, 0.14.0, 1.0.0
    • Fix Version/s: 1.2.0, 1.0.2
    • Component/s: Types
    • Labels:
      None

      Description

      For example:

      select cast(cast('1966-01-01 00:00:01' as timestamp) as date);
      1966-01-02
      

      Another example:

      select last_day(cast('1966-01-31 00:00:01' as timestamp));
      OK
      1966-02-28
      

      more details:
      Date: 1966-01-01 00:00:01
      unix time UTC: -126230399

      daysSinceEpoch=−126230399000 / 86400000 = -1460.999988
      int daysSinceEpoch = -1460
      DateWritable having daysSinceEpoch=-1460 is 1966-01-02

      daysSinceEpoch should be -1461 instead (1966-01-01)

        Attachments

        1. HIVE-10178.01.patch
          5 kB
          Alexander Pivovarov
        2. HIVE-10178.02.patch
          5 kB
          Alexander Pivovarov
        3. HIVE-10178.03.patch
          231 kB
          Alexander Pivovarov
        4. HIVE-10178.03-branch-1.0.patch
          21 kB
          Jason Dere

          Activity

            People

            • Assignee:
              apivovarov Alexander Pivovarov
              Reporter:
              apivovarov Alexander Pivovarov
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: