[
https://issues.apache.org/jira/browse/DRILL-7926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17386289#comment-17386289
]
ASF GitHub Bot commented on DRILL-7926:
---------------------------------------
dzamo edited a comment on pull request #2268:
URL: https://github.com/apache/drill/pull/2268#issuecomment-885702320
For my part, I agree we're now okay fetching the query start time from
ContextInfo like you're doing @oleg-zinovev . The existing utility method
`DateTypeFunctions.getQueryStartDate` follows the same route.
Next, I will share what I've found out trying to clarify your time zone
questions. In Drill, `DATE` and `TIMESTAMP` are zoneless (a.k.a. "naive")
times that are implicitly regarded as in whatever timezone is set by the
parameter `user.timezone`, and which defaults to the time zone of the local
machine. You can set `user.timezone=UTC` and then everything does happen in
UTC.
But Drill's _internal representation_ of these zoneless times, which you're
encountering, is a different story. From what I can see it was decided to use
UNIX times internally, and doing that requires the specification of absolute
time, not just an ambiguous naive time. So the zoneless times coming in from
the outside world, e.g. when I do `select cast('2021-07-23 01:23:45' as
timestamp)` had to be coerced to _some_ timezone and it didn't matter which
one, provided the choice was consitent throughout the codebase including using
same time zone when they did the reverse operation and go from UNIX time back
to a zoneless `TIMESTAMP`.
So here we are. You're using the UTC timezone when you work with
`left.value` and `right.value` and I think that's right. But I think that, as
@paul-rogers says, the query start time you get from the ContextInfo should be
assumed to be in the local time zone. You can test this one quite easily if we
agree that the following query should return an interval of 0s, including when
run on Drillbits that are not in UTC...
```sql
select age(current_date);
```
I ran it with your branch now and I got a number of hours equal to my
timezone offset (2).
--
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)