Skip to content
Snippets Groups Projects
Commit 69da1097 authored by Cam Saul's avatar Cam Saul
Browse files

convert some more tests to be Mongo + H2

parent 2f32181f
Branches
Tags
No related merge requests found
......@@ -16,44 +16,6 @@
{:extra_info {} :special_type nil, :base_type :TextField, :description nil, :name "NAME", :table_id (table->id :venues), :id (field->id :venues :name)}]))
;; ## "SUM" AGGREGATION
(expect {:status :completed
:row_count 1
:data {:rows [[203]]
:columns ["sum"]
:cols [{:base_type :IntegerField
:special_type :category
:name "sum"
:id nil
:table_id nil
:description nil}]}}
(driver/process-query {:type :query
:database @db-id
:query {:source_table (table->id :venues)
:filter [nil nil]
:aggregation ["sum" (field->id :venues :price)]
:breakout [nil]
:limit nil}}))
;; ## "DISTINCT COUNT" AGGREGATION
(expect {:status :completed
:row_count 1
:data {:rows [[15]]
:columns ["count"]
:cols [{:base_type :IntegerField
:special_type :number
:name "count"
:id nil
:table_id nil
:description nil}]}}
(driver/process-query {:type :query
:database @db-id
:query {:source_table (table->id :checkins)
:filter [nil nil]
:aggregation ["distinct" (field->id :checkins :user_id)]
:breakout [nil]
:limit nil}}))
;; ## "AVG" AGGREGATION
;; TODO - try this with an integer field. (Should the average of an integer field be a float or an int?)
(expect {:status :completed,
......
......@@ -17,21 +17,26 @@
(db [this]
"Return `Database` containing test data for this driver.")
(table-name->table [this table-name]
"Given a TABLE-NAME keyword like `:venues`, *fetch* the corresponding `Table`."))
"Given a TABLE-NAME keyword like `:venues`, *fetch* the corresponding `Table`.")
(field-name->id [this table-name field-name]))
(deftype MongoDriverData []
DriverData
(db [_]
@mongo-data/mongo-test-db)
(table-name->table [_ table-name]
(mongo-data/table-name->table table-name)))
(mongo-data/table-name->table table-name))
(field-name->id [_ table-name field-name]
(mongo-data/field-name->id table-name field-name)))
(deftype GenericSqlDriverData []
DriverData
(db [_]
@generic-sql-data/test-db)
(table-name->table [_ table-name]
(generic-sql-data/table-name->table table-name)))
(generic-sql-data/table-name->table table-name))
(field-name->id [_ table-name field-name]
(generic-sql-data/field->id table-name field-name)))
(def driver-name->driver-data
{:mongo (MongoDriverData.)
......@@ -94,6 +99,11 @@
;; {:pre [(integer? *db-id*)]}
;; (-table-name->id *db-id* table-name))))
(defn ->field-id [table-name field-name]
{:pre [*driver-data*]
:post [(integer? %)]}
(field-name->id *driver-data* table-name field-name))
;; ## Driver-Independent QP Tests
......@@ -123,3 +133,35 @@
:aggregation ["count"]
:breakout [nil]
:limit nil})
;; ### "SUM" AGGREGATION
(qp-expect-with-all-drivers
{:rows [[203]]
:columns ["sum"]
:cols [{:base_type :IntegerField
:special_type :category
:name "sum"
:id nil
:table_id nil
:description nil}]}
{:source_table (->table-id :venues)
:filter [nil nil]
:aggregation ["sum" (->field-id :venues :price)]
:breakout [nil]
:limit nil})
;; ### "DISTINCT COUNT" AGGREGATION
(qp-expect-with-all-drivers
{:rows [[15]]
:columns ["count"]
:cols [{:base_type :IntegerField
:special_type :number
:name "count"
:id nil
:table_id nil
:description nil}]}
{:source_table (->table-id :checkins)
:filter [nil nil]
:aggregation ["distinct" (->field-id :checkins :user_id)]
:breakout [nil]
:limit nil})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment