From 37fe1a963a3600a21d1d2378744ab597541fe79b Mon Sep 17 00:00:00 2001 From: Felix Mueller <5407006+enqueue@users.noreply.github.com> Date: Sat, 15 Jun 2019 17:07:10 +0200 Subject: [PATCH] fix count-where, share tests (#15) --- src/metabase/driver/clickhouse.clj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/metabase/driver/clickhouse.clj b/src/metabase/driver/clickhouse.clj index 6ccf14d..210d417 100644 --- a/src/metabase/driver/clickhouse.clj +++ b/src/metabase/driver/clickhouse.clj @@ -187,6 +187,19 @@ (hsql/call :toFloat64 (sql.qp/->honeysql driver arg)))] ((get-method sql.qp/->honeysql [:sql :/]) driver args))) +;; I do not know why the tests expect nil counts for empty results +;; but that's how it is :-) +;; metabase.query-processor-test.count-where-test +;; metabase.query-processor-test.share-test +(defmethod sql.qp/->honeysql [:clickhouse :count-where] + [driver [_ pred]] + (hsql/call :case + (hsql/call :> (hsql/call :count) 0) + (hsql/call :sum (hsql/call :case + (sql.qp/->honeysql driver pred) 1.0 + :else 0.0)) + :else nil)) + (defmethod sql.qp/quote-style :clickhouse [_] :mysql)