            :alias alias
            :select select)))
 
+(defn annotate-column-with-id [table column-id]
+  (annotate-column table (sel :one Field :id column-id)))
+
 (defn annotate-special-column [column]
   (println "COLUMN -> " column)
   (match column

(defn apply-clause [query [clause-name clause-value]]
  (case clause-name
    :filter nil
    :breakout ( apply-breakout query clause-value)
    :limit (when clause-value
             {:limit clause-value})
    :aggregation nil))

             :id nil
             :description nil}))

(defn get-columns
  "Return an array of column info dictionaries for query."
  [{:keys [source_table table breakout aggregation] :as query}]
  (if (= aggregation ["rows"]) (->> (sel :many Field :table_id source_table) ; aggregation: ["rows"] just means return all rows
                                    (map (partial annotate-column table)))
      (->> (concat breakout aggregation)
           (filter identity)
           (map (fn [column]
                  (case (integer? column)
                    true (annotate-column-with-id table column)
                    false (annotate-special-column column)))))))

(defn process [{:keys [source_table] :as query}]
  (assoc* query
          :table (sel :one Table :id source_table)
          :database (:db (-> (:source_table <>)
                             (hydrate :db)))
          :columns (get-columns <>)
          :columns-by-name (->> (:columns <>)
                                (map (fn [{:keys [keyword] :as col}]
                                       {keyword col}))
