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

Convert timestamps to zoned times without string operations

    XMLWordPrintableJSON

Details

    Description

      Parquet DataWriteableWriter relias on NanoTimeUtils to convert a timestamp object into a binary value. The way in which it does this,... it calls toString() on the timestamp object, and then parses the String. This particular timestamp do not carry a timezone, so the string is something like:

      2021-21-03 12:32:23.0000...

      The parse code tries to parse the string assuming there is a time zone, and if not, falls-back and applies the provided "default time zone". As was noted in HIVE-24353, if something fails to parse, it is very expensive to try to parse again. So, for each timestamp in the Parquet file, it:

      • Builds a string from the time stamp
      • Parses it (throws an exception, parses again)

      There is no need to do this kind of string manipulations/parsing, it should just be using the epoch millis/seconds/time stored internal to the Timestamp object.

        // Converts Timestamp to TimestampTZ.
        public static TimestampTZ convert(Timestamp ts, ZoneId defaultTimeZone) {
          return parse(ts.toString(), defaultTimeZone);
        }
      

      Attachments

        Issue Links

          Activity

            People

              belugabehr David Mollitor
              belugabehr David Mollitor
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 6h 10m
                  6h 10m