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

update annotation to handle new expanded :source-table

parent 362c2384
Branches
Tags
No related merge requests found
......@@ -80,7 +80,7 @@
expand
preprocess-cumulative-sum)]
(when-not *disable-qp-logging*
(log/debug (u/format-color 'magenta "\n\nPREPROCESSED/EXPANDED:\n%s" (u/pprint-to-str preprocessed-query))))
(log/debug (u/format-color 'magenta "\n\nPREPROCESSED/EXPANDED:\n%s" (u/pprint-to-str (assoc-in preprocessed-query [:database :details] "**********"))))) ; obscure DB details when logging
preprocessed-query))
......@@ -439,12 +439,12 @@
(defn annotate
"Take a sequence of RESULTS of executing QUERY and return the \"annotated\" results we pass to postprocessing -- the map with `:cols`, `:columns`, and `:rows`.
RESULTS should be a sequence of *maps*, keyed by result column -> value."
[{{:keys [source_table]} :query, :as query}, results & [uncastify-fn]]
{:pre [(integer? source_table)]}
[{{{source-table-id :id} :source-table} :query, :as query}, results & [uncastify-fn]]
{:pre [(integer? source-table-id)]}
(let [results (if-not uncastify-fn results
(for [row results]
(m/map-keys uncastify-fn row)))
fields (sel :many :fields [Field :id :table_id :name :description :base_type :special_type], :table_id source_table, :active true)
fields (sel :many :fields [Field :id :table_id :name :description :base_type :special_type], :table_id source-table-id, :active true)
ordered-col-kws (order-cols query results fields)]
{:rows (for [row results]
(mapv row ordered-col-kws)) ; might as well return each row and col info as vecs because we're not worried about making
......
......@@ -138,12 +138,12 @@
;; ## -------------------- Field + Value --------------------
;; Field is the expansion of a Field ID in the standard QL
(defrecord Field [field-id
field-name
base-type
special-type
table-id
table-name]
(defrecord Field [^Integer field-id
^String field-name
^Keyword base-type
^Keyword special-type
^Integer table-id
^String table-name]
IResolve
(resolve-table [this table-id->table]
(cond-> this
......@@ -153,10 +153,10 @@
;; Information about the associated Field is included for convenience
(defrecord Value [value ; e.g. parsed Date / timestamp
original-value ; e.g. original YYYY-MM-DD string
base-type
special-type
field-id
field-name])
^Keyword base-type
^Keyword special-type
^Integer field-id
^String field-name])
;; ## -------------------- Placeholders --------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment