oleg-zinovev commented on a change in pull request #2268:
URL: https://github.com/apache/drill/pull/2268#discussion_r666157134
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
##########
@@ -424,26 +424,35 @@ public void eval() {
public static class AgeTimeStampFunction implements DrillSimpleFunc {
@Param TimeStampHolder left;
@Param TimeStampHolder right;
+ @Workspace org.joda.time.PeriodType periodType;
@Output IntervalHolder out;
@Override
public void setup() {
+ periodType = org.joda.time.PeriodType.forFields(
+ new org.joda.time.DurationFieldType[] {
+ org.joda.time.DurationFieldType.months(),
+ org.joda.time.DurationFieldType.days(),
+ org.joda.time.DurationFieldType.millis()
+ }
+ );
}
@Override
public void eval() {
- long diff = left.value - right.value;
- long days = diff /
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis;
- out.months = (int) (days /
org.apache.drill.exec.vector.DateUtilities.monthToStandardDays);
- out.days = (int) (days %
org.apache.drill.exec.vector.DateUtilities.monthToStandardDays);
- out.milliseconds = (int) (diff %
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis);
+ org.joda.time.Period interval = new
org.joda.time.Period(right.value, left.value, periodType);
Review comment:
There is no class in Java Time API that would allow working
simultaneously with months and hours / minutes / seconds. However, I can try to
rewrite the fix using java.time.Period and java.time.Duration.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]