Hive
  1. Hive
  2. HIVE-4267

hiveserver2 jdbc driver - remove trailing ".0" in resultset.getString() for timestamp field

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: HiveServer2, JDBC
    • Labels:
      None

      Description

      In case of timestamp field, it is printed with a .0 at the end, which is inconsistent with hive cli. The format without ".0" is compatible with java.sql.Timestamp.valueOf(String).

      1. HIVE-4267.1.patch
        3 kB
        Thejas M Nair

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        2d 59m 1 Thejas M Nair 01/Apr/13 00:03
        Patch Available Patch Available Resolved Resolved
        22h 18m 1 Thejas M Nair 01/Apr/13 22:21
        Owen O'Malley made changes -
        Fix Version/s 0.11.0 [ 12323587 ]
        Thejas M Nair made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]
        Hide
        Thejas M Nair added a comment -

        The jdbc spec doesn't clearly say what representation should be returned by getString() on a timestamp column. But I think what is more natural/less-surprising is to have the value of java.sql.Timestamp.toString() being returned.

        Hive cli code has extra logic to remove the trailing ".0". There might have been some motivations behind that.
        I think it is OK to have this difference in behavior with cli.
        Marking as 'Won't Fix' .

        Show
        Thejas M Nair added a comment - The jdbc spec doesn't clearly say what representation should be returned by getString() on a timestamp column. But I think what is more natural/less-surprising is to have the value of java.sql.Timestamp.toString() being returned. Hive cli code has extra logic to remove the trailing ".0". There might have been some motivations behind that. I think it is OK to have this difference in behavior with cli. Marking as 'Won't Fix' .
        Hide
        Ashutosh Chauhan added a comment -

        This looks a bit odd to me. java.sql.Timestamp which is meant to be jdbc compliant preserves '.0' in toString() If it indeed is compliant than it seems like jdbc driver is currently doing the right thing and cli (TimestampWritable.toString()) is the one which needs to be fixed. It will be good to check if standard says something about resultset.getNext().toString() method when resultset.getNext() is timestamp. If not, than may be a quick test against mysql/postgres jdbc driver will be good to verify.

        Show
        Ashutosh Chauhan added a comment - This looks a bit odd to me. java.sql.Timestamp which is meant to be jdbc compliant preserves '.0' in toString() If it indeed is compliant than it seems like jdbc driver is currently doing the right thing and cli (TimestampWritable.toString()) is the one which needs to be fixed. It will be good to check if standard says something about resultset.getNext().toString() method when resultset.getNext() is timestamp. If not, than may be a quick test against mysql/postgres jdbc driver will be good to verify.
        Hide
        Thejas M Nair added a comment -
        Show
        Thejas M Nair added a comment - reviewboard link - https://reviews.apache.org/r/10212/
        Thejas M Nair made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Thejas M Nair made changes -
        Attachment HIVE-4267.1.patch [ 12576307 ]
        Hide
        Thejas M Nair added a comment -

        HIVE-4267.1.patch is based on HIVE-4269, and that needs to be applied first.

        Show
        Thejas M Nair added a comment - HIVE-4267 .1.patch is based on HIVE-4269 , and that needs to be applied first.
        Thejas M Nair made changes -
        Field Original Value New Value
        Summary fix ResultSet.getString in hiveserver2 jdbc driver for binary, timestamp hiveserver2 jdbc driver - remove trailing ".0" in resultset.getString() for timestamp field
        Description The jdbc driver for hive server2 is printing binary using byte[].toString() instead of first converting it string by using it as a string constructor argument. In case of timestamp field, it is printed with a .0 at the end, which is inconsistent with hive cli.
        In case of timestamp field, it is printed with a .0 at the end, which is inconsistent with hive cli. The format without ".0" is compatible with java.sql.Timestamp.valueOf(String).

        Thejas M Nair created issue -

          People

          • Assignee:
            Thejas M Nair
            Reporter:
            Thejas M Nair
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development