[
https://issues.apache.org/jira/browse/DRILL-7926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17398578#comment-17398578
]
ASF GitHub Bot commented on DRILL-7926:
---------------------------------------
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]
> The " age " function is not working properly.
> ---------------------------------------------
>
> Key: DRILL-7926
> URL: https://issues.apache.org/jira/browse/DRILL-7926
> Project: Apache Drill
> Issue Type: Bug
> Components: Functions - Drill
> Affects Versions: 1.17.0, 1.18.0
> Reporter: Александр Глухов
> Priority: Blocker
> Attachments: image-2021-05-13-16-17-21-154.png, screenshot-1.png,
> screenshot-2.png
>
>
> The " age " function is not working properly.
> *Playback steps*
> {code:sql}
> select extract(year from m. "years") `years` from (select age('2021-05-13',
> '2007-07-02') `years") m{code}
> *Expected result* 13.
> *Actual result* 14.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)