Skip to content

Commit acf7aac

Browse files
🤖 backported "Handle null timestamps for druid" (metabase#75945)
Handle null timestamps for druid (metabase#75350) * fix druid nil timestamp * remove let block * use when-let Co-authored-by: Riley Thompson <riley@metabase.com>
1 parent 54257d1 commit acf7aac

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

modules/drivers/druid-jdbc/src/metabase/driver/druid_jdbc.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
(defmethod sql-jdbc.execute/read-column-thunk [:druid-jdbc Types/TIMESTAMP]
6969
[_driver ^ResultSet rs _rsmeta ^Long i]
7070
(fn []
71-
(t/instant (.getObject rs i))))
71+
(when-let [ts (.getObject rs i)]
72+
(t/instant ts))))
7273

7374
;; Druid's COMPLEX<...> types are encoded as JDBC's other -- 1111. Values are rendered as string.
7475
(defmethod sql-jdbc.execute/read-column-thunk [:druid-jdbc Types/OTHER]

modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,3 +593,11 @@
593593
(mt/rows (qp/process-query query))))
594594
(is (= "select count(1) from checkins where __time >= '2014-04-07'"
595595
(:query (qp.compile/compile-with-inline-parameters query))))))))
596+
597+
(deftest ^:parallel null-timestamp-test
598+
(mt/test-driver :druid-jdbc
599+
(is (= [[nil]]
600+
(-> (mt/metadata-provider)
601+
(lib/native-query "SELECT CAST(NULL AS TIMESTAMP) FROM checkins LIMIT 1")
602+
qp/process-query
603+
mt/rows)))))

0 commit comments

Comments
 (0)