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

test fix

parent aed3ad76
No related branches found
No related tags found
No related merge requests found
(ns metabase.driver.generic-sql.query-processor-test
(:require [expectations :refer :all]
[metabase.driver.generic-sql.query-processor :refer :all]
[metabase.test-data :refer [db-id table->id field->id]]
[metabase.driver.generic-sql.query-processor :refer :all]))
metabase.test-setup))
;; ## "COUNT" AGGREGATION
(expect {:status :completed
......@@ -400,26 +401,16 @@
:aggregation ["cum_sum" (field->id :users :id)]}}))
;; ### Cumulative sum w/ a breakout field
(expect {:status :completed,
:row_count 15,
:data {:rows [[4 #inst "2014-01-01T08:00:00.000-00:00"] ; incidentally this also tests that the QP is casting timestamps -> date
[12 #inst "2014-02-01T08:00:00.000-00:00"]
[13 #inst "2014-04-01T07:00:00.000-00:00"]
[22 #inst "2014-04-03T07:00:00.000-00:00"]
[34 #inst "2014-07-02T07:00:00.000-00:00"]
[44 #inst "2014-07-03T07:00:00.000-00:00"]
[57 #inst "2014-08-01T07:00:00.000-00:00"]
[72 #inst "2014-08-01T07:00:00.000-00:00"]
[78 #inst "2014-08-02T07:00:00.000-00:00"]
[85 #inst "2014-08-02T07:00:00.000-00:00"]
[90 #inst "2014-10-03T07:00:00.000-00:00"]
[104 #inst "2014-10-03T07:00:00.000-00:00"]
[115 #inst "2014-11-01T07:00:00.000-00:00"]
[118 #inst "2014-11-06T08:00:00.000-00:00"]
[120 #inst "2014-12-05T08:00:00.000-00:00"]]
:columns ["ID" "CAST(LAST_LOGIN AS DATE)"]
:cols [{:special_type "id", :base_type "IntegerField", :description nil, :name "ID", :table_id (table->id :users), :id (field->id :users :id)}
{:special_type nil, :base_type "DateTimeField", :description nil, :name "LAST_LOGIN", :table_id (table->id :users), :id (field->id :users :last_login)}]}}
;; incidentally this also tests that the QP is casting timestamps -> date
(expect (let [sorted-user-timestamps (->> metabase.test-data.data/test-data :users :rows (map last) sort)]
{:status :completed,
:row_count 15,
:data {:rows (map vector ; convert to a seq like [[4 timestamp-1] [12 timestamp-2] ...]
[4 12 13 22 34 44 57 72 78 85 90 104 115 118 120] ; by pairing values with corresponding ordered timestamp
sorted-user-timestamps) ; that way we don't have to hard code the last_logins here
:columns ["ID" "CAST(LAST_LOGIN AS DATE)"]
:cols [{:special_type "id", :base_type "IntegerField", :description nil, :name "ID", :table_id (table->id :users), :id (field->id :users :id)}
{:special_type nil, :base_type "DateTimeField", :description nil, :name "LAST_LOGIN", :table_id (table->id :users), :id (field->id :users :last_login)}]}})
(process-and-run {:type :query
:database @db-id
:query {:limit nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment