You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2022/10/05 19:59:19 UTC

[GitHub] [phoenix] stoty commented on pull request #1501: PHOENIX-5422 Use Java8 DateTime APIs instead of joda-time APIs

stoty commented on PR #1501:
URL: https://github.com/apache/phoenix/pull/1501#issuecomment-1264953605

   I agree with you @gjacoby126, but let me provide some context:
   
   In my experience the Chronology issue has less to with real historical use cases than with being able to handle synthetic "minus infinity" constants like '01-01-01' or '1000-01-01' consistently.
   
   The reason we stuck with GJChornology at the last change was because that's what Phoenix has effectively been using already, based on the default behaviour of java.util.Calendar, and this was the easiest way to be consistent on the read and write paths (and date functions) and between Joda and j.u.Calendar, which is still extensively used in Phoenix code.
   
   GJ is also the only Chronology that works without surprises with naive java Date code, i.e. when you do 
   
   ```
   // assume we're in UTC
   j.u.t.Date d = new j.u.d(1000,1,1,1,1,1);
   // write d to Phoenix with a PreparedStatement
   // read d back
   assertEquals("1000-01-01 01:01:01", rs.getString("d"))
   ```
   
   It is only going to succeed with GJChronology (or similar, like BritishCutoverChronology).
   
   Consequently, as long as Phoenix uses j.u.Date / Calender with the default Chronology, it is the only Calendar that can guarantee internal consistency in Phoenix.
   The above is also true for views on HBase tables where custom timestamps are naively generated.
   
   In a nutshell, GJChronology is the default chronology for j.u.Calendar/Date, while ISOChronology is the default for Joda and java.time, and we need to handle this discrepancy somehow.
   
   At the same time, using a cutover chronology is both against the standard, and has a performance cost, so I support using ISOChronology as the default, and basically pruging all j.u.Date/Calendar code from Phoenix.
   
   However, for backwards compatibility both with existing code and existing data, I believe that we also ought to make Chronology configurable.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org