dzamo commented on a change in pull request #2284:
URL: https://github.com/apache/drill/pull/2284#discussion_r688408215



##########
File path: 
exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/TimestampDiffFunction.java
##########
@@ -72,25 +72,11 @@ public void eval() {
     <#elseif unit == "Week">
       out.value = (right.value - left.value) / 604800000; // 7 * 24 * 60 * 60 
* 1000
     <#elseif unit == "Month" || unit == "Quarter" || unit == "Year">
-      long timeMilliseconds = left.value % 
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis
-          - right.value % 
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis;
-
-      java.time.Period between = java.time.Period.between(
-          
java.time.Instant.ofEpochMilli(left.value).atZone(java.time.ZoneOffset.UTC).toLocalDate(),
-          
java.time.Instant.ofEpochMilli(right.value).atZone(java.time.ZoneOffset.UTC).toLocalDate());
-      int days = between.getDays();
-      if (timeMilliseconds < 0 && days > 0) {
-        // in the case of negative time value increases left operand days value
-        between = java.time.Period.between(
-            java.time.Instant.ofEpochMilli(left.value + 
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis).atZone(java.time.ZoneOffset.UTC).toLocalDate(),
-            
java.time.Instant.ofEpochMilli(right.value).atZone(java.time.ZoneOffset.UTC).toLocalDate());
-      } else if (timeMilliseconds > 0 && days < 0) {
-        // in the case of negative days value decreases it for the right 
operand
-        between = java.time.Period.between(
-            java.time.Instant.ofEpochMilli(left.value - 
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis).atZone(java.time.ZoneOffset.UTC).toLocalDate(),
-            
java.time.Instant.ofEpochMilli(right.value).atZone(java.time.ZoneOffset.UTC).toLocalDate());
-      }
-      int months = between.getMonths() + between.getYears() * 
org.apache.drill.exec.vector.DateUtilities.yearsToMonths;
+
+      java.time.LocalDateTime from = 
java.time.Instant.ofEpochMilli(left.value).atZone(java.time.ZoneOffset.UTC).toLocalDateTime();
+      java.time.LocalDateTime to = 
java.time.Instant.ofEpochMilli(right.value).atZone(java.time.ZoneOffset.UTC).toLocalDateTime();

Review comment:
       See my first comment.




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