                           (range categories-count)))
        ");"))
 
-(defn run-query [conn dataset query filter-str]
+(defn apply-pivot [conn dataset query filter-str]
   (let [categories (unique-values conn
                                   (:table-name dataset)
                                   (:category-column query)

                        {:as-arrays? true}))
     :columns columns}))

(defn find-column [columns column-name]
  (first (filter #(= column-name (get % "columnName"))
                 columns)))

(defn build-query
  "Replace column names with proper column metadata from the dataset"

  (def q {"categoryColumn" "c16"
          "rowColumn" "c4"
          "valueColumn" "c19"
          "aggregation" "avg"
          "filters" [{"column" "c2"
                      "columnType" "text"
                      "operation" "keep"
                      "strategy" "is"
                      "value" "Ethiopia"}]})

  (def empty-q {"categoryColumn" nil
                "rowColumn" nil
                "valueColumn" nil
                "aggregation" "count"
                "filters" []})

  (query tenant-conn dataset-id empty-q)

  (unique-categories tenant-conn dataset-id)

