oleg-zinovev commented on a change in pull request #2268:
URL: https://github.com/apache/drill/pull/2268#discussion_r672009640



##########
File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
##########
@@ -425,43 +425,73 @@ public void eval() {
         @Param TimeStampHolder left;
         @Param TimeStampHolder right;
         @Output IntervalHolder out;
+        @Inject ContextInformation contextInfo;
 
         @Override
         public void setup() {
         }
 
         @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);
+            java.time.OffsetDateTime from = 
java.time.Instant.ofEpochMilli(right.value).atOffset(java.time.ZoneOffset.UTC);
+            java.time.OffsetDateTime to = 
java.time.Instant.ofEpochMilli(left.value).atOffset(java.time.ZoneOffset.UTC);
+            java.time.Duration duration = 
java.time.Duration.between(from.toLocalTime(), to.toLocalTime());
+            java.time.Period period;
+
+            if (from.isAfter(to) && 
duration.compareTo(java.time.Duration.ZERO) > 0) {

Review comment:
       The implementation has been simplified, is it necessary to create a 
separate function?




-- 
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]


Reply via email to