Skip to content

Commit

Permalink
Merge pull request #116 from dacort/fix/athena-v3-cast
Browse files Browse the repository at this point in the history
Remove timestamp casts from date_add
  • Loading branch information
dacort authored Nov 6, 2022
2 parents fe93480 + 3dec67b commit 631d746
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

ARG METABASE_VERSION=v0.44.4
ARG METABASE_VERSION=v0.44.6

FROM clojure:openjdk-11-tools-deps-slim-buster AS stg_base

Expand Down
6 changes: 3 additions & 3 deletions src/metabase/driver/athena.clj
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@

; If `expr` is a date, we need to cast it to a timestamp before we can truncate to a finer granularity
; Ideally, we should make this conditional. There's a generic approach above, but different use cases should b tested.
(defmethod sql.qp/date [:athena :minute] [_ _ expr] (hsql/call :date_trunc (hx/literal :minute) (expr->literal expr)))
(defmethod sql.qp/date [:athena :hour] [_ _ expr] (hsql/call :date_trunc (hx/literal :hour) (expr->literal expr)))
(defmethod sql.qp/date [:athena :minute] [_ _ expr] (hsql/call :date_trunc (hx/literal :minute) expr))
(defmethod sql.qp/date [:athena :hour] [_ _ expr] (hsql/call :date_trunc (hx/literal :hour) expr))
(defmethod sql.qp/date [:athena :day] [_ _ expr] (hsql/call :date_trunc (hx/literal :day) expr))
(defmethod sql.qp/date [:athena :week] [_ _ expr] (hsql/call :date_trunc (hx/literal :week) expr))
(defmethod sql.qp/date [:athena :month] [_ _ expr] (hsql/call :date_trunc (hx/literal :month) expr))
Expand All @@ -152,7 +152,7 @@
(hsql/call :date_add
(hx/literal (name unit))
(hsql/raw (int amount))
(hx/->timestamp hsql-form)))
hsql-form))

;; fix to allow integer division to be cast as double (float is not supported by athena)
(defmethod sql.qp/->float :athena
Expand Down

0 comments on commit 631d746

Please sign in to comment.