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

The result of TimestampWritableV2.toString() is wrong when year is larger than 9999.

    XMLWordPrintableJSON

Details

    Description

      Hi, I found that `TimestampWritableV2.toString()` can be wrong when year is larger than 9999. Here is what I get:

      • test code:
        // code placeholder
        @Test
        public void testTimestampWritableV2toString() {
          TimestampWritableV2 timestampWritableV2 = new TimestampWritableV2(
              Timestamp.valueOf("10001-01-01 01:01:23"));
          
          assertEquals("+10001-01-01 01:01:23", timestampWritableV2.toString());
        }
      • output:
      // code placeholder
      org.junit.ComparisonFailure:
       Expected :+10001-01-01 01:01:23
       Actual :+10001-01-01 01:01:2323
      

      The patch below removes some 'wrong' code in `TimestampWritableV2.toString()`, for the reason that the length of `org.apache.hadoop.hive.common.type.Timestamp#toString` can be larger than 19, even its nano-of-second is zero.

      Attachments

        Issue Links

          Activity

            People

              Qiang.Kang Qiang.Kang
              Qiang.Kang Qiang.Kang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h