diff --git a/src/metabase/driver/snowflake.clj b/src/metabase/driver/snowflake.clj index 9d87ce6a4f70731faf40154fac8b4bcb57a0443c..001c57a9920dbc9a038472d5fd2434f293982656 100644 --- a/src/metabase/driver/snowflake.clj +++ b/src/metabase/driver/snowflake.clj @@ -14,8 +14,8 @@ [metabase.util [honeysql-extensions :as hx] [ssh :as ssh]] - [toucan.db :as db] - [clojure.java.jdbc :as jdbc])) + [toucan.db :as db]) + (:import java.sql.Time)) (defn- connection-details->spec "Create a database specification for a snowflake database." @@ -141,6 +141,10 @@ (let [{table-name :name, schema :schema} table] (hx/qualify-and-escape-dots (query-db-name) schema table-name))) +(defmethod sql.qp/->honeysql [SnowflakeDriver :time] + [driver [_ value unit]] + (hx/->time (sql.qp/->honeysql driver value))) + (defn- field->identifier "Generate appropriate identifier for a Field for SQL parameters. (NOTE: THIS IS ONLY USED FOR SQL PARAMETERS!)" ;; TODO - Making a DB call for each field to fetch its Table is inefficient and makes me cry, but this method is diff --git a/test/metabase/query_processor_test/time_field_test.clj b/test/metabase/query_processor_test/time_field_test.clj index ef2c40ac2d06c82d968a11c8cf0596ee00758246..4d419fc3cc2f3394d1a0ad0e802cb80b744078e2 100644 --- a/test/metabase/query_processor_test/time_field_test.clj +++ b/test/metabase/query_processor_test/time_field_test.clj @@ -79,6 +79,12 @@ (= :mysql *engine*) [] + ;; It looks like Snowflake is doing this conversion correctly. Snowflake's time field is stored as wall clock time + ;; (vs. PG and others storing it without a timezone). Originally, this time is 16:15 in UTC, which is 8:15 in + ;; pacific time. The other report timezone databases are not doing this timezone conversion. + (= :snowflake *engine*) + [[3 "Kaneonuskatew Eiran" "08:15:00.000-08:00"]] + ;; Databases like PostgreSQL ignore timezone information when ;; using a time field, the result below is what happens when the ;; 08:00 time is interpreted as UTC, then not adjusted to Pacific