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_r281948355
##########
File path:
exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalIntervalArithmetic.java
##########
@@ -64,8 +64,17 @@ public void eval() {
<#elseif intervaltype == "IntervalYear">
out.value = left.value + right.value;
<#elseif intervaltype == "IntervalDay">
+ long millis = (long) left.milliseconds + right.milliseconds;
out.days = left.days + right.days;
- out.milliseconds = left.milliseconds + right.milliseconds;
+
+ // Subtracts all full days from millis
+ if (millis >
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis - 1) {
Review comment:
```suggestion
if (millis >=
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis) {
// Extract days from millis and add them to out.days
int daysFromMillis = (int) (millis /
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis);
millis -= daysFromMillis *
org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis;
out.days += daysFromMillis;
}
```
----------------------------------------------------------------
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