Skip to content
Snippets Groups Projects
Commit 5938404e authored by Simon Belak's avatar Simon Belak
Browse files

Use query metadata rather than Field metadata

parent eee6f266
No related branches found
No related tags found
No related merge requests found
......@@ -67,11 +67,11 @@
(defmethod extract-features (type Field)
[opts field]
(let [dataset (values/field-values field (extract-query-opts opts))]
{:features (->> dataset
(let [{:keys [field row]} (values/field-values field (extract-query-opts opts))]
{:features (->> row
(field->features opts field)
(merge {:table (Table (:table_id field))}))
:sample? (sampled? opts dataset)}))
:sample? (sampled? opts row)}))
(defmethod extract-features (type Table)
[opts table]
......
......@@ -503,9 +503,7 @@
(#{:day :month :year :quarter :week} unit))
{:histogram-hour (redux/pre-step
h/histogram-categorical
;; TOFIX: this is an ugly workaround
#(when (and % (not (instance? java.sql.Date %)))
(.getHours ^java.util.Date %)))})))
(somef (memfn ^java.util.Date getHours)))})))
(merge-juxt
histogram-extractor
(field-metadata-extractor field)
......
......@@ -7,16 +7,16 @@
(defn field-values
"Return all the values of FIELD for QUERY."
[{:keys [id table_id] :as field} query]
(->> (qp/process-query
{:type :query
:database (metadata/db-id field)
:query (-> query
(ql/source-table table_id)
(ql/fields id))
:middleware {:format-rows? false}})
:data
:rows
(map first)))
(let [{:keys [rows cols]} (->> (qp/process-query
{:type :query
:database (metadata/db-id field)
:query (-> query
(ql/source-table table_id)
(ql/fields id))
:middleware {:format-rows? false}})
:data)]
{:row (map first rows)
:field (first cols)}))
(defn query-values
"Return all values for QUERY."
......
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