     :else []))
 
 (defn shape-aggregation-sql
-  [tenant-conn columns table-name geom-column popup-columns point-color-column where-clause current-layer layer-index]
+  [tenant-conn columns geom-column popup-columns point-color-column where-clause current-layer layer-index]
   (let [{:keys [table-name columns]} (db.dataset/dataset-by-id tenant-conn {:id (:aggregationDataset current-layer)})
         point-table-name table-name
         point-columns columns

            where-clause)))

(defn get-sql
  [tenant-conn columns table-name geom-column popup-columns point-color-column
   where-clause {:keys [aggregationDataset aggregationColumn
                        aggregationGeomColumn layerType]
                 :as layer} layer-index]
  (cond

    (= layerType "raster")
    (format "SELECT * FROM %s" table-name)

    (and aggregationDataset aggregationColumn aggregationGeomColumn)
    (shape-aggregation-sql tenant-conn columns table-name geom-column
                           popup-columns (:columnName point-color-column) where-clause layer
                           layer-index)

    (= layerType "geo-shape")
    (shape-sql tenant-conn columns table-name geom-column popup-columns
               (:columnName point-color-column) where-clause layer)

    :else
    (point-sql tenant-conn columns table-name geom-column popup-columns
               point-color-column where-clause layer)))

(defn get-interactivity

                        table-name
                        where-clause)))

(defn shape-sql [tenant-conn columns geom-column popup-columns point-color-column where-clause
                 {:keys [datasetId shapeLabelColumn ] :as layer}]
  (let [{:keys [table-name columns]} (db.dataset/dataset-by-id tenant-conn {:id datasetId})
        date-column-set (reduce (fn [m {:strs [columnName type]}]
