Skip to content
Snippets Groups Projects
Commit eddeac51 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #2301 from metabase/fix-dt-without-timezone-response

if no report timezone is set, use the JVM timezone for our QP datetime formatting.
parents 33b18dde 4d7d6a07
No related branches found
No related tags found
No related merge requests found
......@@ -114,7 +114,8 @@
:resource-paths ["test_resources"]
:env {:mb-test-setting-1 "ABCDEFG"
:mb-run-mode "test"}
:jvm-opts ["-Dmb.db.in.memory=true"
:jvm-opts ["-Duser.timezone=UTC"
"-Dmb.db.in.memory=true"
"-Dmb.jetty.join=false"
"-Dmb.jetty.port=3010"
"-Dmb.api.key=test-api-key"
......
......@@ -148,7 +148,10 @@
(for [row rows]
(for [v row]
(if (u/is-temporal? v)
(u/->iso-8601-datetime v report-timezone)
;; NOTE: if we don't have an explicit report-timezone then use the JVM timezone
;; this ensures alignment between the way dates are processed by JDBC and our returned data
;; GH issues: #2282, #2035
(u/->iso-8601-datetime v (or report-timezone (System/getProperty "user.timezone")))
v))))
(defn- post-format-rows
......
......@@ -881,29 +881,29 @@
;; SQL Server, Mongo, and Redshift don't have a concept of timezone so results are all grouped by UTC
(i/has-questionable-timezone-support? *data-loader*)
[["2015-06-01T07:00:00.000Z" 6]
["2015-06-02T07:00:00.000Z" 10]
["2015-06-03T07:00:00.000Z" 4]
["2015-06-04T07:00:00.000Z" 9]
["2015-06-05T07:00:00.000Z" 9]
["2015-06-06T07:00:00.000Z" 8]
["2015-06-07T07:00:00.000Z" 8]
["2015-06-08T07:00:00.000Z" 9]
["2015-06-09T07:00:00.000Z" 7]
["2015-06-10T07:00:00.000Z" 9]]
[["2015-06-01T00:00:00.000Z" 6]
["2015-06-02T00:00:00.000Z" 10]
["2015-06-03T00:00:00.000Z" 4]
["2015-06-04T00:00:00.000Z" 9]
["2015-06-05T00:00:00.000Z" 9]
["2015-06-06T00:00:00.000Z" 8]
["2015-06-07T00:00:00.000Z" 8]
["2015-06-08T00:00:00.000Z" 9]
["2015-06-09T00:00:00.000Z" 7]
["2015-06-10T00:00:00.000Z" 9]]
;; Postgres, MySQL, and H2 -- grouped by DB timezone, US/Pacific in this case
:else
[["2015-06-01T07:00:00.000Z" 8]
["2015-06-02T07:00:00.000Z" 9]
["2015-06-03T07:00:00.000Z" 9]
["2015-06-04T07:00:00.000Z" 4]
["2015-06-05T07:00:00.000Z" 11]
["2015-06-06T07:00:00.000Z" 8]
["2015-06-07T07:00:00.000Z" 6]
["2015-06-08T07:00:00.000Z" 10]
["2015-06-09T07:00:00.000Z" 6]
["2015-06-10T07:00:00.000Z" 10]])
[["2015-06-01T00:00:00.000Z" 8]
["2015-06-02T00:00:00.000Z" 9]
["2015-06-03T00:00:00.000Z" 9]
["2015-06-04T00:00:00.000Z" 4]
["2015-06-05T00:00:00.000Z" 11]
["2015-06-06T00:00:00.000Z" 8]
["2015-06-07T00:00:00.000Z" 6]
["2015-06-08T00:00:00.000Z" 10]
["2015-06-09T00:00:00.000Z" 6]
["2015-06-10T00:00:00.000Z" 10]])
(->> (dataset sad-toucan-incidents
(run-query incidents
(ql/aggregation (ql/count))
......@@ -1228,18 +1228,6 @@
(expect-with-non-timeseries-dbs
(cond
(contains? #{:redshift :sqlserver :bigquery} *engine*)
[["2015-06-01T17:31:00.000Z" 1]
["2015-06-01T23:06:00.000Z" 1]
["2015-06-02T00:23:00.000Z" 1]
["2015-06-02T01:55:00.000Z" 1]
["2015-06-02T04:04:00.000Z" 1]
["2015-06-02T04:19:00.000Z" 1]
["2015-06-02T09:13:00.000Z" 1]
["2015-06-02T12:37:00.000Z" 1]
["2015-06-02T15:20:00.000Z" 1]
["2015-06-02T18:11:00.000Z" 1]]
(= *engine* :sqlite)
[["2015-06-01 10:31:00" 1]
["2015-06-01 16:06:00" 1]
......@@ -1252,7 +1240,7 @@
["2015-06-02 08:20:00" 1]
["2015-06-02 11:11:00" 1]]
:else
(contains? #{:redshift :sqlserver :bigquery :mongo :postgres :h2} *engine*)
[["2015-06-01T10:31:00.000Z" 1]
["2015-06-01T16:06:00.000Z" 1]
["2015-06-01T17:23:00.000Z" 1]
......@@ -1262,7 +1250,19 @@
["2015-06-02T02:13:00.000Z" 1]
["2015-06-02T05:37:00.000Z" 1]
["2015-06-02T08:20:00.000Z" 1]
["2015-06-02T11:11:00.000Z" 1]])
["2015-06-02T11:11:00.000Z" 1]]
:else
[["2015-06-01T03:31:00.000Z" 1]
["2015-06-01T09:06:00.000Z" 1]
["2015-06-01T10:23:00.000Z" 1]
["2015-06-01T11:55:00.000Z" 1]
["2015-06-01T14:04:00.000Z" 1]
["2015-06-01T14:19:00.000Z" 1]
["2015-06-01T19:13:00.000Z" 1]
["2015-06-01T22:37:00.000Z" 1]
["2015-06-02T01:20:00.000Z" 1]
["2015-06-02T04:11:00.000Z" 1]])
(sad-toucan-incidents-with-bucketing :default))
(expect-with-non-timeseries-dbs
......@@ -1280,18 +1280,6 @@
["2015-06-02 11:11:00" 1]]
(i/has-questionable-timezone-support? *data-loader*)
[["2015-06-01T17:31:00.000Z" 1]
["2015-06-01T23:06:00.000Z" 1]
["2015-06-02T00:23:00.000Z" 1]
["2015-06-02T01:55:00.000Z" 1]
["2015-06-02T04:04:00.000Z" 1]
["2015-06-02T04:19:00.000Z" 1]
["2015-06-02T09:13:00.000Z" 1]
["2015-06-02T12:37:00.000Z" 1]
["2015-06-02T15:20:00.000Z" 1]
["2015-06-02T18:11:00.000Z" 1]]
:else
[["2015-06-01T10:31:00.000Z" 1]
["2015-06-01T16:06:00.000Z" 1]
["2015-06-01T17:23:00.000Z" 1]
......@@ -1301,7 +1289,19 @@
["2015-06-02T02:13:00.000Z" 1]
["2015-06-02T05:37:00.000Z" 1]
["2015-06-02T08:20:00.000Z" 1]
["2015-06-02T11:11:00.000Z" 1]])
["2015-06-02T11:11:00.000Z" 1]]
:else
[["2015-06-01T03:31:00.000Z" 1]
["2015-06-01T09:06:00.000Z" 1]
["2015-06-01T10:23:00.000Z" 1]
["2015-06-01T11:55:00.000Z" 1]
["2015-06-01T14:04:00.000Z" 1]
["2015-06-01T14:19:00.000Z" 1]
["2015-06-01T19:13:00.000Z" 1]
["2015-06-01T22:37:00.000Z" 1]
["2015-06-02T01:20:00.000Z" 1]
["2015-06-02T04:11:00.000Z" 1]])
(sad-toucan-incidents-with-bucketing :minute))
(expect-with-non-timeseries-dbs
......@@ -1332,18 +1332,6 @@
["2015-06-02 13:00:00" 1]]
(i/has-questionable-timezone-support? *data-loader*)
[["2015-06-01T17:00:00.000Z" 1]
["2015-06-01T23:00:00.000Z" 1]
["2015-06-02T00:00:00.000Z" 1]
["2015-06-02T01:00:00.000Z" 1]
["2015-06-02T04:00:00.000Z" 2]
["2015-06-02T09:00:00.000Z" 1]
["2015-06-02T12:00:00.000Z" 1]
["2015-06-02T15:00:00.000Z" 1]
["2015-06-02T18:00:00.000Z" 1]
["2015-06-02T20:00:00.000Z" 1]]
:else
[["2015-06-01T10:00:00.000Z" 1]
["2015-06-01T16:00:00.000Z" 1]
["2015-06-01T17:00:00.000Z" 1]
......@@ -1353,7 +1341,19 @@
["2015-06-02T05:00:00.000Z" 1]
["2015-06-02T08:00:00.000Z" 1]
["2015-06-02T11:00:00.000Z" 1]
["2015-06-02T13:00:00.000Z" 1]])
["2015-06-02T13:00:00.000Z" 1]]
:else
[["2015-06-01T03:00:00.000Z" 1]
["2015-06-01T09:00:00.000Z" 1]
["2015-06-01T10:00:00.000Z" 1]
["2015-06-01T11:00:00.000Z" 1]
["2015-06-01T14:00:00.000Z" 2]
["2015-06-01T19:00:00.000Z" 1]
["2015-06-01T22:00:00.000Z" 1]
["2015-06-02T01:00:00.000Z" 1]
["2015-06-02T04:00:00.000Z" 1]
["2015-06-02T06:00:00.000Z" 1]])
(sad-toucan-incidents-with-bucketing :hour))
(expect-with-non-timeseries-dbs
......@@ -1377,28 +1377,28 @@
["2015-06-10" 9]]
(i/has-questionable-timezone-support? *data-loader*)
[["2015-06-01T07:00:00.000Z" 6]
["2015-06-02T07:00:00.000Z" 10]
["2015-06-03T07:00:00.000Z" 4]
["2015-06-04T07:00:00.000Z" 9]
["2015-06-05T07:00:00.000Z" 9]
["2015-06-06T07:00:00.000Z" 8]
["2015-06-07T07:00:00.000Z" 8]
["2015-06-08T07:00:00.000Z" 9]
["2015-06-09T07:00:00.000Z" 7]
["2015-06-10T07:00:00.000Z" 9]]
[["2015-06-01T00:00:00.000Z" 6]
["2015-06-02T00:00:00.000Z" 10]
["2015-06-03T00:00:00.000Z" 4]
["2015-06-04T00:00:00.000Z" 9]
["2015-06-05T00:00:00.000Z" 9]
["2015-06-06T00:00:00.000Z" 8]
["2015-06-07T00:00:00.000Z" 8]
["2015-06-08T00:00:00.000Z" 9]
["2015-06-09T00:00:00.000Z" 7]
["2015-06-10T00:00:00.000Z" 9]]
:else
[["2015-06-01T07:00:00.000Z" 8]
["2015-06-02T07:00:00.000Z" 9]
["2015-06-03T07:00:00.000Z" 9]
["2015-06-04T07:00:00.000Z" 4]
["2015-06-05T07:00:00.000Z" 11]
["2015-06-06T07:00:00.000Z" 8]
["2015-06-07T07:00:00.000Z" 6]
["2015-06-08T07:00:00.000Z" 10]
["2015-06-09T07:00:00.000Z" 6]
["2015-06-10T07:00:00.000Z" 10]])
[["2015-06-01T00:00:00.000Z" 8]
["2015-06-02T00:00:00.000Z" 9]
["2015-06-03T00:00:00.000Z" 9]
["2015-06-04T00:00:00.000Z" 4]
["2015-06-05T00:00:00.000Z" 11]
["2015-06-06T00:00:00.000Z" 8]
["2015-06-07T00:00:00.000Z" 6]
["2015-06-08T00:00:00.000Z" 10]
["2015-06-09T00:00:00.000Z" 6]
["2015-06-10T00:00:00.000Z" 10]])
(sad-toucan-incidents-with-bucketing :day))
(expect-with-non-timeseries-dbs
......@@ -1429,18 +1429,18 @@
["2015-06-28" 7]]
(i/has-questionable-timezone-support? *data-loader*)
[["2015-05-31T07:00:00.000Z" 46]
["2015-06-07T07:00:00.000Z" 47]
["2015-06-14T07:00:00.000Z" 40]
["2015-06-21T07:00:00.000Z" 60]
["2015-06-28T07:00:00.000Z" 7]]
[["2015-05-31T00:00:00.000Z" 46]
["2015-06-07T00:00:00.000Z" 47]
["2015-06-14T00:00:00.000Z" 40]
["2015-06-21T00:00:00.000Z" 60]
["2015-06-28T00:00:00.000Z" 7]]
:else
[["2015-05-31T07:00:00.000Z" 49]
["2015-06-07T07:00:00.000Z" 47]
["2015-06-14T07:00:00.000Z" 39]
["2015-06-21T07:00:00.000Z" 58]
["2015-06-28T07:00:00.000Z" 7]])
[["2015-05-31T00:00:00.000Z" 49]
["2015-06-07T00:00:00.000Z" 47]
["2015-06-14T00:00:00.000Z" 39]
["2015-06-21T00:00:00.000Z" 58]
["2015-06-28T00:00:00.000Z" 7]])
(sad-toucan-incidents-with-bucketing :week))
(expect-with-non-timeseries-dbs
......@@ -1449,7 +1449,7 @@
(contains? #{:sqlserver :sqlite} *engine*)
[[23 54] [24 46] [25 39] [26 61]]
(contains? #{:mongo :redshift :bigquery} *engine*)
(contains? #{:mongo :redshift :bigquery :postgres :h2} *engine*)
[[23 46] [24 47] [25 40] [26 60] [27 7]]
:else
......@@ -1457,7 +1457,7 @@
(sad-toucan-incidents-with-bucketing :week-of-year))
(expect-with-non-timeseries-dbs
[[(if (= *engine* :sqlite) "2015-06-01", "2015-06-01T07:00:00.000Z") 200]]
[[(if (= *engine* :sqlite) "2015-06-01", "2015-06-01T00:00:00.000Z") 200]]
(sad-toucan-incidents-with-bucketing :month))
(expect-with-non-timeseries-dbs
......@@ -1465,7 +1465,7 @@
(sad-toucan-incidents-with-bucketing :month-of-year))
(expect-with-non-timeseries-dbs
[[(if (= *engine* :sqlite) "2015-04-01", "2015-04-01T07:00:00.000Z") 200]]
[[(if (= *engine* :sqlite) "2015-04-01", "2015-04-01T00:00:00.000Z") 200]]
(sad-toucan-incidents-with-bucketing :quarter))
(expect-with-non-timeseries-dbs
......
......@@ -96,5 +96,5 @@
:engine (constantly :h2)
:format-name (fn [_ table-or-field-name]
(s/upper-case table-or-field-name))
:has-questionable-timezone-support? (constantly false)
:has-questionable-timezone-support? (constantly true)
:id-field-type (constantly :BigIntegerField)}))
......@@ -42,4 +42,6 @@
(merge generic/IDatasetLoaderMixin
{:database->connection-details database->connection-details
:default-schema (constantly "public")
:engine (constantly :postgres)}))
:engine (constantly :postgres)
;; TODO: this is suspect, but it works
:has-questionable-timezone-support? (constantly true)}))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment