Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-5066

The TimeZone is incorrectly used during writing or reading data

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 5.0.0, 4.14.1
    • 5.2.0, 5.1.4
    • None
    • None
    • Hide
      Adds the phoenix.query.applyTimeZoneDisplacement attribute, which enables applying timezone displacement when setting or retriteving java.sql. time types via PreparedSatetement and ResultSet objects.

      Setting the attribute will result in interpreting the epoch-based java.sql time types in the local timezone.

      This attribute is off by default for backwards compatibility reasons, and needs to be enabled explicitly. This is a client side attribute, and can be set on a per connection basis.
      Show
      Adds the phoenix.query.applyTimeZoneDisplacement attribute, which enables applying timezone displacement when setting or retriteving java.sql. time types via PreparedSatetement and ResultSet objects. Setting the attribute will result in interpreting the epoch-based java.sql time types in the local timezone. This attribute is off by default for backwards compatibility reasons, and needs to be enabled explicitly. This is a client side attribute, and can be set on a per connection basis.

    Description

      We have two methods to write data when uses JDBC API.
      #1. Uses the exceuteUpdate method to execute a string that is an upsert SQL.
      #2. Uses the prepareStatement method to set some objects and execute.

      The string data needs to convert to a new object by the schema information of tables. we'll use some date formatters to convert string data to object for Date/Time/Timestamp types when writes data and the formatters are used when reads data as well.

       

      Uses default timezone test

       Writing 3 records by the different ways.

      UPSERT INTO date_test VALUES (1,'2018-12-10 15:40:47','2018-12-10 15:40:47','2018-12-10 15:40:47') 
      UPSERT INTO date_test VALUES (2,to_date('2018-12-10 15:40:47'),to_time('2018-12-10 15:40:47'),to_timestamp('2018-12-10 15:40:47'))
      stmt.setInt(1, 3);stmt.setDate(2, date);stmt.setTime(3, time);stmt.setTimestamp(4, ts);
      

      Reading the table by the getObject(getDate/getTime/getTimestamp) methods.

      1 | 2018-12-10 | 23:45:07 | 2018-12-10 23:45:07.0 
      2 | 2018-12-10 | 23:45:07 | 2018-12-10 23:45:07.0 
      3 | 2018-12-10 | 15:45:07 | 2018-12-10 15:45:07.66 
      

      Reading the table by the getString methods 

      1 | 2018-12-10 15:45:07.000 | 2018-12-10 15:45:07.000 | 2018-12-10 15:45:07.000 
      2 | 2018-12-10 15:45:07.000 | 2018-12-10 15:45:07.000 | 2018-12-10 15:45:07.000 
      3 | 2018-12-10 07:45:07.660 | 2018-12-10 07:45:07.660 | 2018-12-10 07:45:07.660
      

       Uses GMT+8 test

       Writing 3 records by the different ways.

      UPSERT INTO date_test VALUES (1,'2018-12-10 15:40:47','2018-12-10 15:40:47','2018-12-10 15:40:47')
      
      UPSERT INTO date_test VALUES (2,to_date('2018-12-10 15:40:47'),to_time('2018-12-10 15:40:47'),to_timestamp('2018-12-10 15:40:47'))
      stmt.setInt(1, 3);stmt.setDate(2, date);stmt.setTime(3, time);stmt.setTimestamp(4, ts);
      

      Reading the table by the getObject(getDate/getTime/getTimestamp) methods.

      1 | 2018-12-10 | 23:40:47 | 2018-12-10 23:40:47.0 
      2 | 2018-12-10 | 15:40:47 | 2018-12-10 15:40:47.0 
      3 | 2018-12-10 | 15:40:47 | 2018-12-10 15:40:47.106 

      Reading the table by the getString methods

       1 | 2018-12-10 23:40:47.000 | 2018-12-10 23:40:47.000 | 2018-12-10 23:40:47.000
      2 | 2018-12-10 15:40:47.000 | 2018-12-10 15:40:47.000 | 2018-12-10 15:40:47.000
      3 | 2018-12-10 15:40:47.106 | 2018-12-10 15:40:47.106 | 2018-12-10 15:40:47.106
      

       

      We have a historical problem,  we'll parse the string to Date/Time/Timestamp objects with timezone in #1, which means the actual data is going to be changed when stored in HBase table。

      Attachments

        1. PHOENIX-5066.master.v6.patch
          174 kB
          Richárd Antal
        2. PHOENIX-5066.master.v5.patch
          27 kB
          Richárd Antal
        3. PHOENIX-5066.master.v4.patch
          24 kB
          Richárd Antal
        4. PHOENIX-5066.master.v3.patch
          19 kB
          Richárd Antal
        5. PHOENIX-5066.master.v2.patch
          18 kB
          Richárd Antal
        6. PHOENIX-5066.master.v1.patch
          18 kB
          Richárd Antal
        7. PHOENIX-5066.4x.v3.patch
          19 kB
          Richárd Antal
        8. PHOENIX-5066.4x.v2.patch
          18 kB
          Richárd Antal
        9. PHOENIX-5066.4x.v1.patch
          54 kB
          Richárd Antal
        10. DateTest.java
          3 kB
          Jaanai Zhang

        Issue Links

          Activity

            People

              stoty Istvan Toth
              jaanai Jaanai Zhang
              Votes:
              1 Vote for this issue
              Watchers:
              14 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 - 20m
                  20m