Paul Rogers created DRILL-5372:
----------------------------------
Summary: IntervalVector.getObject() returns non-normalized Period
Key: DRILL-5372
URL: https://issues.apache.org/jira/browse/DRILL-5372
Project: Apache Drill
Issue Type: Bug
Reporter: Paul Rogers
Priority: Minor
The Drill {{IntervalVector.Accessor}} class provides a method to return the
interval as a Joda {{Period}}:
{code}
public Period getObject(int index) {
final int offsetIndex = index * 16;
final int months = data.getInt(offsetIndex);
final int days = data.getInt(offsetIndex + 4);
final int millis = data.getInt(offsetIndex + 8);
final Period p = new Period();
return p.plusMonths(months).plusDays(days).plusMillis(millis);
}
{code}
This method returns the {{Period}} in non-normalized format. That is, the
months field can contain a month count greater than 12 (rather than setting the
year field and month field.)
Similarly, the millisecond field contains the entire time portion, rather than
setting the hour, minute, second and ms fields.
What seems to be happening is that the code uses {{Period}} as a handy way to
represent the Drill type rather than effectively converting the Drill type to
the Joda {{Period}} format.
The workaround is to call the {{.normalizedStandard()}} method on the returned
value:
{code}
IntervalVector.Accessor accessor = ...
Period p = accessor.getObject(rowNo).normalizedStandard();
{code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)