Skip to content

Commit 9b0fc09

Browse files
authored
#10 Fix remapping tests (#31)
* #10 Consistently use DECIMAL data type for numbers * Add test for DECIMAL with decimal places
1 parent 0e240df commit 9b0fc09

File tree

7 files changed

+48
-50
lines changed

7 files changed

+48
-50
lines changed

doc/changes/changes_0.3.0.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# metabase-driver 0.3.0, released 2022-01-??
1+
# metabase-driver 0.3.0, released 2022-02-04
22

33
Code name: Enable SSH tunnel and improve error messages
44

@@ -8,6 +8,8 @@ In this release we enable connecting to Exasol through an SSH tunnel (see the [u
88

99
We also explain how to use data types `TIMESTAMP` and `TIMESTAMP WITH LOCAL TIME ZONE` with timezones in the [user guide](../user_guide/user_guide.md#timestamps-and-time-zone).
1010

11+
Additionally we now correctly map `INTEGER` and `SMALLINT` columns to Metabase's type `:type/Decimal`.
12+
1113
## Features
1214

1315
* #25: Enabled SSH tunnel for connecting to Exasol
@@ -17,3 +19,7 @@ We also explain how to use data types `TIMESTAMP` and `TIMESTAMP WITH LOCAL TIME
1719

1820
* Improved the installation instructions in the [user guide](../user_guide/user_guide.md#installing-the-driver)
1921
* #9: Explained how to use data types `TIMESTAMP` and `TIMESTAMP WITH LOCAL TIME ZONE` with timezones
22+
23+
## Tests
24+
25+
* #10: Fixed remapping tests

scripts/exclude_tests.diff

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,6 @@ index f21aca9a7c..5ee692d226 100644
137137
(is (= 1
138138
(count (mt/rows (mt/dataset string-times
139139
(mt/run-mbql-query times
140-
diff --git a/test/metabase/query_processor_test/breakout_test.clj b/test/metabase/query_processor_test/breakout_test.clj
141-
index 015ff7fdd3..db03598e12 100644
142-
--- a/test/metabase/query_processor_test/breakout_test.clj
143-
+++ b/test/metabase/query_processor_test/breakout_test.clj
144-
@@ -65,7 +65,7 @@
145-
:limit 10}))))))))))
146-
147-
(deftest internal-remapping-test
148-
- (mt/test-drivers (mt/normal-drivers)
149-
+ (mt/test-drivers (disj (mt/normal-drivers) :exasol) ; https://github.com/exasol/metabase-driver/issues/10
150-
(mt/with-column-remappings [venues.category_id (values-of categories.name)]
151-
(let [{:keys [rows cols]} (qp.test/rows-and-cols
152-
(mt/format-rows-by [int int str]
153140
diff --git a/test/metabase/query_processor_test/parameters_test.clj b/test/metabase/query_processor_test/parameters_test.clj
154141
index f1de41d12e..7986f53406 100644
155142
--- a/test/metabase/query_processor_test/parameters_test.clj
@@ -167,24 +154,6 @@ diff --git a/test/metabase/query_processor_test/remapping_test.clj b/test/metaba
167154
index 70b172130f..8a40f4ca91 100644
168155
--- a/test/metabase/query_processor_test/remapping_test.clj
169156
+++ b/test/metabase/query_processor_test/remapping_test.clj
170-
@@ -9,7 +9,7 @@
171-
[toucan.db :as db]))
172-
173-
(deftest basic-remapping-test
174-
- (mt/test-drivers (mt/normal-drivers)
175-
+ (mt/test-drivers (disj (mt/normal-drivers) :exasol) ; https://github.com/exasol/metabase-driver/issues/10
176-
(mt/with-column-remappings [venues.category_id (values-of categories.name)]
177-
(is (= {:rows [["20th Century Cafe" 12 "Café"]
178-
["25°" 11 "Burger"]
179-
@@ -54,7 +54,7 @@
180-
[(dissoc c1 :source_alias) c2 (dissoc agg :base_type :effective_type)]))))))))
181-
182-
(deftest nested-remapping-test
183-
- (mt/test-drivers (mt/normal-drivers-with-feature :nested-queries)
184-
+ (mt/test-drivers (disj (mt/normal-drivers-with-feature :nested-queries) :exasol) ; https://github.com/exasol/metabase-driver/issues/10
185-
(mt/with-column-remappings [venues.category_id (values-of categories.name)]
186-
(is (= {:rows [["20th Century Cafe" 12 "Café"]
187-
["25°" 11 "Burger"]
188157
@@ -170,7 +170,7 @@
189158
;;
190159
;; Having a self-referencing FK is currently broken with the Redshift and Oracle backends. The issue related to fix

src/metabase/driver/exasol.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@
9898
[#"^BOOLEAN$" :type/Boolean]
9999
[#"^CHAR$" :type/Text]
100100
[#"^VARCHAR$" :type/Text]
101-
[#"^BIGINT$" :type/Decimal]
102101
[#"^DECIMAL$" :type/Decimal]
102+
[#"^BIGINT$" :type/Decimal] ; Precision <= 18
103+
[#"^INTEGER$" :type/Decimal] ; Precision <= 9
104+
[#"^SMALLINT$" :type/Decimal] ; Precision <= 4
103105
[#"^DOUBLE PRECISION$" :type/Float]
104106
[#"^DOUBLE$" :type/Float]
105107
[#"^DATE$" :type/Date]

test/metabase/driver/exasol_test.clj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
(deftest exasol-data-types
2727
(mt/test-driver :exasol
2828
(td/dataset exasol-dataset/exasol-data-types
29-
(is (= [["null-values" nil nil nil nil]
30-
["non-null-values" "550e8400e29b11d4a716446655440000" "+05-03" "+02 12:50:10.123" "POINT (2 5)"]]
31-
(mt/rows (mt/run-mbql-query "data_types" {:fields [$name $hash $interval_ytm $interval_dts $geo]
29+
(is (= [["null-values" nil nil nil nil nil]
30+
["non-null-values" "550e8400e29b11d4a716446655440000" "+05-03" "+02 12:50:10.123" "POINT (2 5)" 123.45M]]
31+
(mt/rows (mt/run-mbql-query "data_types" {:fields [$name $hash $interval_ytm $interval_dts $geo $decimal_5_2]
3232
:order-by [[:asc $row_order]]})))))))
3333

3434
(deftest join-test
@@ -101,9 +101,9 @@
101101
(deftest math-functions
102102
(testing "Exasol supports math functions, e.g. POWER()"
103103
(mt/test-driver :exasol
104-
(is (= [[3 9.0]
105-
[2 4.0]
106-
[2 4.0]]
104+
(is (= [[3M 9.0]
105+
[2M 4.0]
106+
[2M 4.0]]
107107
(mt/rows
108108
(mt/run-mbql-query venues
109109
{:expressions {"test" [:power [:field-id $price] 2]}
@@ -229,9 +229,9 @@
229229
(deftest iso-8601-text-fields
230230
(testing "text fields with semantic_type :type/ISO8601DateTimeString"
231231
(mt/test-drivers #{:exasol}
232-
(is (= [[1 "foo" #t "2004-10-19T10:23:54" #t "2004-10-19"]
233-
[2 "bar" #t "2008-10-19T10:23:54" #t "2008-10-19"]
234-
[3 "baz" #t "2012-10-19T10:23:54" #t "2012-10-19"]]
232+
(is (= [[1M "foo" #t "2004-10-19T10:23:54" #t "2004-10-19"]
233+
[2M "bar" #t "2008-10-19T10:23:54" #t "2008-10-19"]
234+
[3M "baz" #t "2012-10-19T10:23:54" #t "2012-10-19"]]
235235
(mt/rows (mt/dataset alt-date-test/just-dates
236236
(qp/process-query
237237
(assoc (mt/mbql-query just-dates)

test/metabase/test/data/exasol.clj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@
3838

3939
(defmethod tx/has-questionable-timezone-support? :exasol [_] true)
4040

41+
(defonce ^:private number-column-type
42+
"DECIMAL(36,0)")
43+
4144
(doseq [[base-type sql-type] {:type/Text "VARCHAR(4000)"
42-
:type/BigInteger "DECIMAL(36,0)"
43-
:type/Integer "DECIMAL(18,0)"
44-
:type/Decimal "DECIMAL(18,0)"
45+
:type/BigInteger number-column-type
46+
:type/Integer number-column-type
47+
:type/Decimal number-column-type
4548
:type/Float "DOUBLE PRECISION"
4649
:type/Boolean "BOOLEAN"
4750
:type/Date "DATE"
@@ -100,7 +103,7 @@
100103
(apply execute/sequentially-execute-sql! args))
101104

102105
(defmethod sql.tx/pk-sql-type :exasol [_]
103-
"INTEGER IDENTITY NOT NULL")
106+
(str number-column-type " IDENTITY NOT NULL"))
104107

105108
(defmethod sql.tx/qualified-name-components :exasol [& args]
106109
(apply tx/single-db-qualified-name-components session-schema args))

test/metabase/test/data/exasol_dataset_definitions.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
{:field-name "hash", :base-type {:native "HASHTYPE"}}
1212
{:field-name "interval_ytm", :base-type {:native "INTERVAL YEAR TO MONTH"}}
1313
{:field-name "interval_dts", :base-type {:native "INTERVAL DAY TO SECOND"}}
14-
{:field-name "geo", :base-type {:native "GEOMETRY"}}]
14+
{:field-name "geo", :base-type {:native "GEOMETRY"}}
15+
{:field-name "decimal_5_2", :base-type {:native "DECIMAL(5,2)"}}
16+
]
1517
[; Rows
16-
[0 "null-values" nil nil nil nil]
17-
[1 "non-null-values" "550e8400-e29b-11d4-a716-446655440000" "5-3" "2 12:50:10.123" "POINT(2 5)"]]]])
18+
[0 "null-values" nil nil nil nil nil]
19+
[1 "non-null-values" "550e8400-e29b-11d4-a716-446655440000" "5-3" "2 12:50:10.123" "POINT(2 5)" 123.45]]]])
1820

1921
(tx/defdataset timestamp-data
2022
"Test data with timestamp types"

test_unit/metabase/driver/exasol_test.clj

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
["CHAR" :type/Text]
6262
["VARCHAR" :type/Text]
6363
["BIGINT" :type/Decimal]
64+
["INTEGER" :type/Decimal]
65+
["SMALLINT" :type/Decimal]
6466
["DECIMAL" :type/Decimal]
6567
["DOUBLE PRECISION" :type/Float]
6668
["DOUBLE" :type/Float]
@@ -104,10 +106,24 @@
104106
(deftest current-datetime-honeysql-form-test
105107
(is (= (hsql/raw "SYSTIMESTAMP") (sql.qp/current-datetime-honeysql-form :exasol))))
106108

107-
(deftest ->honeysql-test
109+
(deftest regex-match-first->honeysql-test
108110
(testing :regex-match-first
109111
(is (= (hsql/call :regexp_substr "arg" "pattern") (sql.qp/->honeysql :exasol [:regex-match-first "arg" "pattern"])))))
110112

113+
(deftest substring->honeysql-test
114+
(testing "substring without length argument"
115+
(is (= (hsql/call :substring "arg" 4) (sql.qp/->honeysql :exasol [:substring "arg" 4]))))
116+
(testing "substring with length argument"
117+
(is (= (hsql/call :substring "arg" 4 6) (sql.qp/->honeysql :exasol [:substring "arg" 4 6])))))
118+
119+
(deftest concat->honeysql-test
120+
(testing "concat with single argument"
121+
(is (= (hsql/call :concat "arg1") (sql.qp/->honeysql :exasol [:concat "arg1"]))))
122+
(testing "concat with two arguments"
123+
(is (= (hsql/call :concat "arg1" "arg2") (sql.qp/->honeysql :exasol [:concat "arg1" "arg2"]))))
124+
(testing "concat with three arguments"
125+
(is (= (hsql/call :concat "arg1" "arg2" "arg3") (sql.qp/->honeysql :exasol [:concat "arg1" "arg2" "arg3"])))))
126+
111127
(deftest add-interval-honeysql-form-test
112128
(let [hsql-form (hx/literal "5")
113129
amount 42

0 commit comments

Comments
 (0)