You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "Istvan Toth (Jira)" <ji...@apache.org> on 2023/03/14 13:19:00 UTC

[jira] [Commented] (PHOENIX-6902) Switch to ISOChronology or make it configurable

    [ https://issues.apache.org/jira/browse/PHOENIX-6902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17700159#comment-17700159 ] 

Istvan Toth commented on PHOENIX-6902:
--------------------------------------

Based on my current underdstanding, this is what Phoenix SHOULD do:
 * Store all temporals internally using ISO8601 (preleptic Gregorian) chronology.
 * Use ISO8601 chronology for date functions internally
 * Parse and format all dates received and returned in String parameters and literals in ISO8601 chronology
 * Use ISO8601 Chronology to convert temporals received or returned as java.time.Local* in ISO8601 chronology (effectively do nothing, that's how we internally store them)
 * For incoming java.sql.* temporals in PreparedStatement.set*() methods
 ** use Calendar.setTime(input) to convert to Calendar. Use the provided Calendar or the default java.util.GregorianCalendar in the local TZ
 ** Create a LocalDateTime from the calendar fields.
 ** get the UTC epoch from the LocalDateTime as usual
 * For outgoing java.sql.* temporals in ResultSet.get*() methods

 ** Create a LocalDateTime from the internal epoch value in UTC (as usual)
 ** Set the date fields for the Calendar from the LocalDateTime. Use the provided Calendar, or default java.util.GregorianCalendar in the local TZ
 ** use Calendar.getDate() to construct the outgoing value.

The Calendar machinations described have two purposes:
- Convert the epoch value from the java.util.GregorianCalendar's cutover chronology to ISOChronology
- Apply the timezone displacement

We can probably write some much faster code that skips the Calendar and Local* conversions, and uses the existing displacement methods for the timezone,
and a simpler logic for applying the cutover date conversion.

> Switch to ISOChronology or make it configurable
> -----------------------------------------------
>
>                 Key: PHOENIX-6902
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6902
>             Project: Phoenix
>          Issue Type: Bug
>          Components: core
>            Reporter: Istvan Toth
>            Assignee: Istvan Toth
>            Priority: Major
>
> Phoenix has historically used the default java.util.GregorianCalendar , and its Joda implementation, org.joda.time.chrono.GJChronology.
> However, both the SQL standard, and the modern java.time library uses ISOChronology.
> Either switch to ISOChronology, or preferably add an option to switch between GregorianCalendar and ISOChronology.
> AFAIU this would have to be a system-wide config.
> This is closely related to switching to the java.time API internally.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)