Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.9.0
-
None
-
None
-
None
Description
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:
@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; }
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, 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 |
TIME WITH TIMEZONE | OffsetTime |
TIMESTAMP WITH TIMEZONE | OffsetDateTime |
Attachments
Issue Links
- is related to
-
DRILL-5332 DateVector support uses questionable conversions to a time
- Open
- relates to
-
DRILL-4060 CTAS to csv or json files gives incorrect time values
- Open
-
DRILL-6242 Output format for nested date, time, timestamp values in an object hierarchy
- Resolved