Skip to content
Snippets Groups Projects
Commit 3769b0d3 authored by Cam Saül's avatar Cam Saül
Browse files

Minor cleanup :beach: [ci skip]

parent a33e45d1
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,8 @@
[clojure.tools.logging :as log]
[clojure.tools.namespace.find :as ns-find]
[medley.core :as m]
[metabase.db :as db]
(metabase [config :as config]
[db :as db])
(metabase.models [database :refer [Database]]
[query-execution :refer [QueryExecution]]
[setting :refer [defsetting]])
......@@ -266,16 +267,14 @@
"Search Classpath for namespaces that start with `metabase.driver.`, then `require` them and look for the `driver-init`
function which provides a uniform way for Driver initialization to be done."
[]
(doseq [namespce (filter (fn [ns-symb]
(re-matches #"^metabase\.driver\.[a-z0-9_]+$" (name ns-symb)))
(ns-find/find-namespaces (classpath/classpath)))]
(require namespce)))
(doseq [ns-symb (ns-find/find-namespaces (classpath/classpath))
:when (re-matches #"^metabase\.driver\.[a-z0-9_]+$" (name ns-symb))]
(require ns-symb)))
(defn is-engine?
"Is ENGINE a valid driver name?"
[engine]
(when engine
(contains? (set (keys (available-drivers))) (keyword engine))))
(contains? (available-drivers) (keyword engine)))
(defn driver-supports?
"Tests if a driver supports a given feature."
......
......@@ -18,19 +18,21 @@
[metabase.test.util :as tu]
[metabase.util :as u]))
;;; ------------------------------------------------------------ Dataset-Independent QP Tests ------------------------------------------------------------
;;; ------------------------------------------------------------ Helper Fns + Macros ------------------------------------------------------------
;; Event-Based DBs aren't tested here, but in `event-query-processor-test` instead.
(def ^:private ^:const timeseries-engines #{:druid})
(def ^:private ^:const non-timeseries-engines (set/difference datasets/all-valid-engines timeseries-engines))
;; Make sure the driver test extension namespaces are loaded. This is needed because otherwise `lein test metabase.query-processor-test` won't work
(doseq [engine non-timeseries-engines
:let [driver-test-ns (symbol (str "metabase.test.data." (name engine)))]]
(require driver-test-ns :reload))
(defn- engines-that-support [feature]
(set (filter (fn [engine]
(contains? (driver/features (driver/engine->driver engine)) feature))
non-timeseries-engines)))
(set (for [engine non-timeseries-engines
:when (contains? (driver/features (driver/engine->driver engine)) feature)]
engine)))
(defn- engines-that-dont-support [feature]
(set/difference non-timeseries-engines (engines-that-support feature)))
......@@ -265,6 +267,7 @@
(defn rows
"Return the result rows from query results, or throw an Exception if they're missing."
{:style/indent 0}
[results]
(vec (or (-> results :data :rows)
(println (u/pprint-to-str 'red results))
......@@ -1926,9 +1929,8 @@
[2 "Lucky Pigeon"]
[5 "Peter Pelican"]
[1 "Ronald Raven"]]
(tu/obj->json->obj
(dataset avian-singles
(rows (run-query messages
(ql/aggregation (ql/count))
(ql/breakout $sender_id->users.name)
(ql/filter (ql/= $reciever_id->users.name "Rasta Toucan")))))))
(dataset avian-singles
(rows (run-query messages
(ql/aggregation (ql/count))
(ql/breakout $sender_id->users.name)
(ql/filter (ql/= $reciever_id->users.name "Rasta Toucan"))))))
[["users" [{:field-name "name"
:base-type :TextField}]
:base-type :CharField}]
[["Rasta Toucan"]
["Lucky Pigeon"]
["Peter Pelican"]
......@@ -15,7 +15,7 @@
:base-type :IntegerField
:fk :users}
{:field-name "text"
:base-type :TextField}]
:base-type :CharField}]
[[8 7 "Coo"]
[8 3 "Bip bip bip bip"]
[3 2 "Coo"]
......
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