-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Druid filters in configured timezone #3420
Conversation
Awesome. Could you add some tests that show the bug so we can make sure there are no regressions in the future? |
(date-trunc unit (System/currentTimeMillis))) | ||
(^java.sql.Timestamp [unit date] | ||
(let [trunc-with-format (fn trunc-with-format | ||
(^java.sql.Timestamp [unit date timezone-id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely going to break things, there's lots of places in the code where we user this function and they're not passing the extra timezone arg
@moumny, the changes you made in |
The current iteration of If you need to pass a third argument then a better solution would be to add a third arity of the function |
Sorry should have put WIP in the title. We should probably add some test in timeseries testsuite that take into account the report timezone and test the timestamp filters. Would need bit of help for that ^^. (especially that mongo for example filters still in UTC i guess) Still todo: verifiy that i didnt break mongo driver |
✅ mongodb tests are passing :) |
@moumny this is looking good but as I mentioned above
i.e. if "UTC" is basically the default (defn date-extract
([unit]
(date-extract unit (System/currentTimeMillis)))
([unit date]
(date-extract unit date "UTC"))
([unit date timezone-id])
...)) That way the Mongo driver wouldn't have to be changed at all. It looks like you did this with |
@@ -229,6 +231,7 @@ | |||
:year (extract:timeFormat "yyyy"))) | |||
|
|||
(defn- unit->granularity [unit] | |||
(let [timeZone (get-timezone-id)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this being used?
trunc-with-floor (fn [date amount-ms] | ||
(let [orig-ms (.getTime (->Timestamp date)) | ||
trunced-ms (-> orig-ms (/ amount-ms) (math/floor) (* amount-ms))] | ||
(new java.sql.Timestamp trunced-ms))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you should probably just do (->Timestamp trunced-ms)
(expect #inst "2005-12-25-08:00" (date-trunc :week saturday-the-31st "US/Pacific")) | ||
(expect #inst "2005-12-25-08:00" (date-trunc :week sunday-the-1st "US/Pacific")) | ||
(expect #inst "2005-12-01-08:00" (date-trunc :month saturday-the-31st "US/Pacific")) | ||
(expect #inst "2005-10-01-08:00" (date-trunc :quarter saturday-the-31st "US/Pacific")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on the extra tests
Thanks for your comment @camsaul ! Anyway let me know if you see something else. 👁 |
@moumny, this looks good 👍 . I'll run it on CI in a bit and if all the tests pass then we can merge this Thanks for your contribution 😍 |
Related to #3386 .
Filters in druid (intervals) are now made in the report timezone configured instead of UTC.