drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vitalii Diravka (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (DRILL-5334) Questionable code in the TimeVector class
Date Tue, 30 May 2017 15:25:04 GMT

     [ https://issues.apache.org/jira/browse/DRILL-5334?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Vitalii Diravka reassigned DRILL-5334:

    Assignee:     (was: Vitalii Diravka)

> Questionable code in the TimeVector class
> -----------------------------------------
>                 Key: DRILL-5334
>                 URL: https://issues.apache.org/jira/browse/DRILL-5334
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 1.9.0
>            Reporter: Paul Rogers
> The {{TimeVector}} class, which holds Time data, should hold a simple local time with
no associated date or time zone. (A local time cannot be converted to UTC without a date since
the conversion depends on when daylight savings is in effect.)
> But, the implementation of {{TimeVector}} uses the following very questionable code:
> {code}
>     @Override
>     public DateTime getObject(int index) {
>         org.joda.time.DateTime time = new org.joda.time.DateTime(get(index), org.joda.time.DateTimeZone.UTC);
>         time = time.withZoneRetainFields(org.joda.time.DateTimeZone.getDefault());
>         return time;
>     }
> {code}
> That is, we convert a date-less, local time into a Joda UTC DateTime object, then reset
the time zone to local time. This is abusing the Joda library and is the very kind of fun
& games that Joda was designed to prevent.
> The conversion of a time into Joda should use the {{LocalTime}} class.
> In fact, according to [Oracle|http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html],
the following is the mapping from ANSI SQL date/time types to Java 8 (and thus Joda) classes:
> ||ANSI SQL||Java SE 8
> |DATE|LocalDate
> |TIME|LocalTime
> |TIMESTAMP|LocalDateTime

This message was sent by Atlassian JIRA

View raw message