Skip to content
Snippets Groups Projects
Unverified Commit b033197e authored by Cam Saul's avatar Cam Saul
Browse files

Don't run date-bucketing tests for Snowflake; fix fetching timezone

parent df3cad62
Branches
Tags
No related merge requests found
......@@ -22,6 +22,7 @@
[metabase.models
[database :refer [Database]]
[setting :refer [defsetting]]]
[metabase.query-processor.store :as qp.store]
[metabase.sync.interface :as si]
[metabase.util
[date :as du]
......@@ -407,13 +408,16 @@
parses the date returned preserving it's timezone"
[native-query date-formatters]
(fn [driver database]
{:pre [(map? database)]}
(let [settings (when-let [report-tz (report-timezone-if-supported driver)]
{:settings {:report-timezone report-tz}})
time-str (try
(->> (merge settings {:database database, :native {:query native-query}})
(execute-query driver)
:rows
ffirst)
(qp.store/with-store
(qp.store/store-database! database)
(->> (merge settings {:database database, :native {:query native-query}})
(execute-query driver)
:rows
ffirst))
(catch Exception e
(throw
(Exception.
......
......@@ -810,29 +810,29 @@
(cons :relative-datetime relative-datetime-args)]}))
first-row first int))
;; HACK - Don't run these tests against BigQuery because the databases need to be loaded every time the tests are ran
;; and loading data into BigQuery is mind-bogglingly slow. Don't worry, I promise these work though!
;; HACK - Don't run these tests against BigQuery/etc. because the databases need to be loaded every time the tests are ran
;; and loading data into BigQuery/etc. is mind-bogglingly slow. Don't worry, I promise these work though!
;; Don't run the minute tests against Oracle because the Oracle tests are kind of slow and case CI to fail randomly
;; when it takes so long to load the data that the times are no longer current (these tests pass locally if your
;; machine isn't as slow as the CircleCI ones)
(expect-with-non-timeseries-dbs-except #{:bigquery :oracle} 4 (count-of-grouping (checkins:4-per-minute) :minute "current"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery :oracle} 4 (count-of-grouping (checkins:4-per-minute) :minute "current"))
(expect-with-non-timeseries-dbs-except #{:bigquery :oracle} 4 (count-of-grouping (checkins:4-per-minute) :minute -1 "minute"))
(expect-with-non-timeseries-dbs-except #{:bigquery :oracle} 4 (count-of-grouping (checkins:4-per-minute) :minute 1 "minute"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery :oracle} 4 (count-of-grouping (checkins:4-per-minute) :minute -1 "minute"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery :oracle} 4 (count-of-grouping (checkins:4-per-minute) :minute 1 "minute"))
(expect-with-non-timeseries-dbs-except #{:bigquery} 4 (count-of-grouping (checkins:4-per-hour) :hour "current"))
(expect-with-non-timeseries-dbs-except #{:bigquery} 4 (count-of-grouping (checkins:4-per-hour) :hour -1 "hour"))
(expect-with-non-timeseries-dbs-except #{:bigquery} 4 (count-of-grouping (checkins:4-per-hour) :hour 1 "hour"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery} 4 (count-of-grouping (checkins:4-per-hour) :hour "current"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery} 4 (count-of-grouping (checkins:4-per-hour) :hour -1 "hour"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery} 4 (count-of-grouping (checkins:4-per-hour) :hour 1 "hour"))
(expect-with-non-timeseries-dbs-except #{:bigquery} 1 (count-of-grouping (checkins:1-per-day) :day "current"))
(expect-with-non-timeseries-dbs-except #{:bigquery} 1 (count-of-grouping (checkins:1-per-day) :day -1 "day"))
(expect-with-non-timeseries-dbs-except #{:bigquery} 1 (count-of-grouping (checkins:1-per-day) :day 1 "day"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery} 1 (count-of-grouping (checkins:1-per-day) :day "current"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery} 1 (count-of-grouping (checkins:1-per-day) :day -1 "day"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery} 1 (count-of-grouping (checkins:1-per-day) :day 1 "day"))
(expect-with-non-timeseries-dbs-except #{:bigquery} 7 (count-of-grouping (checkins:1-per-day) :week "current"))
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery} 7 (count-of-grouping (checkins:1-per-day) :week "current"))
;; SYNTACTIC SUGAR
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
1
(-> (data/with-temp-db [_ (checkins:1-per-day)]
(data/run-mbql-query checkins
......@@ -840,7 +840,7 @@
:filter [:time-interval $timestamp :current :day]}))
first-row first int))
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
7
(-> (data/with-temp-db [_ (checkins:1-per-day)]
(data/run-mbql-query checkins
......@@ -862,32 +862,32 @@
(throw (ex-info "Query failed!" results)))
:unit (-> results :data :cols first :unit)}))
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
{:rows 1, :unit :day}
(date-bucketing-unit-when-you :breakout-by "day", :filter-by "day"))
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
{:rows 7, :unit :day}
(date-bucketing-unit-when-you :breakout-by "day", :filter-by "week"))
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
{:rows 1, :unit :week}
(date-bucketing-unit-when-you :breakout-by "week", :filter-by "day"))
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
{:rows 1, :unit :quarter}
(date-bucketing-unit-when-you :breakout-by "quarter", :filter-by "day"))
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
{:rows 1, :unit :hour}
(date-bucketing-unit-when-you :breakout-by "hour", :filter-by "day"))
;; make sure if you use a relative date bucket in the past (e.g. "past 2 months") you get the correct amount of rows
;; (#3910)
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
{:rows 2, :unit :day}
(date-bucketing-unit-when-you :breakout-by "day", :filter-by "day", :with-interval -2))
(expect-with-non-timeseries-dbs-except #{:bigquery}
(expect-with-non-timeseries-dbs-except #{:snowflake :bigquery}
{:rows 2, :unit :day}
(date-bucketing-unit-when-you :breakout-by "day", :filter-by "day", :with-interval 2))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment