Skip to content

Commit 0ead46a

Browse files
authored
Scan SimpleAggregateFunction columns (#148)
1 parent 43f9b95 commit 0ead46a

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

Diff for: CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 1.1.2
2+
3+
### Bug fixes
4+
5+
* Now the driver is able to scan and work with `SimpleAggregateFunction` columns: those were excluded by mistake in 1.0.2.
6+
7+
18
# 1.1.1
29

310
### New features

Diff for: resources/metabase-plugin.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
info:
22
name: Metabase ClickHouse Driver
3-
version: 1.1.1
3+
version: 1.1.2
44
description: Allows Metabase to connect to ClickHouse databases.
55
contact-info:
66
name: ClickHouse

Diff for: src/metabase/driver/clickhouse.clj

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
(def ^:private default-connection-details
7676
{:user "default", :password "", :dbname "default", :host "localhost", :port "8123"})
77-
(def ^:private product-name "metabase/1.1.1")
77+
(def ^:private product-name "metabase/1.1.2")
7878

7979
(defmethod sql-jdbc.conn/connection-details->spec :clickhouse
8080
[_ details]
@@ -161,9 +161,9 @@
161161
(update-in field [:database-type]
162162
;; Enum8(UInt8) -> Enum8
163163
clojure.string/replace #"^(Enum.+)\(.+\)" "$1")]
164-
;; Skip all (Simple)AggregateFunction columns
164+
;; Skip all AggregateFunction (but keeping SimpleAggregateFunction) columns
165165
;; JDBC does not support that and it crashes the data browser
166-
:when (not (re-matches #"^.*AggregateFunction\(.+$"
166+
:when (not (re-matches #"^AggregateFunction\(.+$"
167167
(get field :database-type)))]
168168
updated-field)]
169169
(merge table-metadata {:fields (set filtered-fields)})))

Diff for: test/metabase/driver/clickhouse_test.clj

+13-3
Original file line numberDiff line numberDiff line change
@@ -511,20 +511,30 @@
511511
(testing "(Simple)AggregateFunction columns are filtered"
512512
(testing "from the table metadata"
513513
(is (= {:name "aggregate_functions_filter_test"
514-
:fields #{{:name "i"
514+
:fields #{{:name "idx"
515515
:database-type "UInt8"
516516
:base-type :type/Integer
517517
:database-position 0
518518
; TODO: in Metabase 0.45.0-RC this returned true,
519519
; and now it is false, which is strange, cause it is not Nullable in the DDL
520+
:database-required false}
521+
{:name "lowest_value"
522+
:database-type "SimpleAggregateFunction(min, UInt8)",
523+
:base-type :type/Integer,
524+
:database-position 2,
525+
:database-required false}
526+
{:name "count"
527+
:database-type "SimpleAggregateFunction(sum, Int64)",
528+
:base-type :type/BigInteger,
529+
:database-position 3,
520530
:database-required false}}}
521531
(ctu/do-with-metabase-test-db
522532
(fn [db]
523533
(driver/describe-table :clickhouse db {:name "aggregate_functions_filter_test"}))))))
524534
(testing "from the result set"
525-
(is (= [[42]]
535+
(is (= [[42 144 255255]]
526536
(qp.test/formatted-rows
527-
[int]
537+
[int int int]
528538
:format-nil-values
529539
(ctu/do-with-metabase-test-db
530540
(fn [db]

Diff for: test/metabase/driver/clickhouse_test_utils.clj

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@
5757
" (2, false, true),"
5858
" (3, true, false);")
5959
(str "CREATE TABLE `metabase_test`.`aggregate_functions_filter_test` ("
60-
" i UInt8, a AggregateFunction(uniq, String), b SimpleAggregateFunction(min, UInt8)"
60+
" idx UInt8, a AggregateFunction(uniq, String), lowest_value SimpleAggregateFunction(min, UInt8),"
61+
" count SimpleAggregateFunction(sum, Int64)"
6162
") ENGINE Memory;")
62-
(str "INSERT INTO `metabase_test`.`aggregate_functions_filter_test` (i) VALUES (42);")]]
63+
(str "INSERT INTO `metabase_test`.`aggregate_functions_filter_test`"
64+
" (idx, lowest_value, count) VALUES (42, 144, 255255);")]]
6365
(jdbc/execute! conn [sql]))))
6466

6567
(defn do-with-metabase-test-db

Diff for: test/metabase/test/data/clickhouse.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
:ssl false
2222
:use_no_proxy false
2323
:use_server_time_zone_for_dates true
24-
:product_name "metabase/1.1.1"})
24+
:product_name "metabase/1.1.2"})
2525

2626
(defmethod sql.tx/field-base-type->sql-type [:clickhouse :type/Boolean] [_ _] "Boolean")
2727
(defmethod sql.tx/field-base-type->sql-type [:clickhouse :type/BigInteger] [_ _] "Int64")

0 commit comments

Comments
 (0)