ihuzenko commented on a change in pull request #1784: DRILL-4782 / DRILL-7139: 
Fix cast and arithmetic for DayInterval 
URL: https://github.com/apache/drill/pull/1784#discussion_r281951934
 
 

 ##########
 File path: 
exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalIntervalArithmetic.java
 ##########
 @@ -90,6 +99,21 @@ public void eval() {
             <#elseif intervaltype == "IntervalDay">
             out.days = left.days - right.days;
             out.milliseconds = left.milliseconds - right.milliseconds;
+
+            // redistribute days stored in millis to days
+            int daysFromMillis = Math.abs(out.milliseconds) / 
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis;
+            if (out.milliseconds > 0) {
+              out.milliseconds = out.milliseconds - 
(org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis * 
daysFromMillis);
+            } else {
+              out.milliseconds = out.milliseconds + 
(org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis * 
daysFromMillis);
+            }
+            out.days -= daysFromMillis;
+
+            // if milliseconds are bellow zero, redistribute them in count of 
whole day
 
 Review comment:
   ```suggestion
              // if milliseconds are bellow zero, try to subtract them from days
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to