   )
 )
 
-(defn shape-aggregagation-popup-sql [popup table-name prefix postfix]
+(defn shape-aggregagation-extra-cols-sql [popup table-name prefix postfix]
   (if
     (= (count popup) 0)
     ""
     (str prefix (clojure.string/join "," (map (fn [popupObj] (str table-name "." (get popupObj "column"))) popup)) postfix)
+  )
+)
+
+(defn popup-and-label-cols [popup-cols label-col]
+  (cond
+    (and (boolean popup-cols) (boolean label-col))
+    (conj popup-cols {"column" label-col})
+
+    (boolean popup-cols)
+    popup-cols
+
+    (boolean label-col)
+    [{"column" label-col}]
+
+    :else
+    []
   )
 )
 

            (get current-layer "aggregationGeomColumn")
            shape-table-name
            (get current-layer "geom")
            (shape-aggregagation-popup-sql (get current-layer "popup") shape-table-name "," "")
            (shape-aggregagation-popup-sql (get current-layer "popup") "temp_table" "" ",")
            (get current-layer "geom")
            hue
            )))

              temp_table;
            "

            (shape-aggregagation-extra-cols-sql extra-cols shape-table-name "" ",")
            shape-table-name
            (get current-layer "geom")
            aggregation-method
