Skip to content
Snippets Groups Projects
Commit fd6d5b07 authored by Cam Saül's avatar Cam Saül Committed by GitHub
Browse files

Merge pull request #4703 from metabase/andrewboltachev-druid_routine

Druid analyze-table implementation [ci drivers]
parents eef61018 29e6b7d6
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
[metabase.driver.druid.query-processor :as qp]
(metabase.models [field :as field]
[table :as table])
[metabase.sync-database.analyze :as analyze]
[metabase.util :as u]))
;;; ### Request helper fns
......@@ -138,6 +139,15 @@
(field-values-lazy-seq details table-name field-name total-items-fetched paging-identifiers)))))))
(defn- analyze-table
"Implementation of `analyze-table` for Druid driver."
[driver table new-table-ids]
((analyze/make-analyze-table driver
:field-avg-length-fn (constantly 0) ; TODO implement this?
:field-percent-urls-fn (constantly 0)
:calculate-row-count? false) driver table new-table-ids))
;;; ### DruidrDriver Class Definition
(defrecord DruidDriver []
......@@ -148,6 +158,7 @@
driver/IDriver
(merge driver/IDriverDefaultsMixin
{:can-connect? (u/drop-first-arg can-connect?)
:analyze-table analyze-table
:describe-database (u/drop-first-arg describe-database)
:describe-table (u/drop-first-arg describe-table)
:details-fields (constantly [{:name "host"
......
......@@ -186,12 +186,13 @@
(defn make-analyze-table
"Make a generic implementation of `analyze-table`."
{:style/indent 1}
[driver & {:keys [field-avg-length-fn field-percent-urls-fn]
[driver & {:keys [field-avg-length-fn field-percent-urls-fn calculate-row-count?]
:or {field-avg-length-fn (partial driver/default-field-avg-length driver)
field-percent-urls-fn (partial driver/default-field-percent-urls driver)}}]
field-percent-urls-fn (partial driver/default-field-percent-urls driver)
calculate-row-count? true}}]
(fn [driver table new-field-ids]
(let [driver (assoc driver :field-avg-length field-avg-length-fn, :field-percent-urls field-percent-urls-fn)]
{:row_count (u/try-apply table-row-count table)
{:row_count (when calculate-row-count? (u/try-apply table-row-count table))
:fields (for [{:keys [id] :as field} (table/fields table)]
(let [new-field? (contains? new-field-ids id)]
(cond->> {:id id}
......
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