 
             [["extract" column ["group_by" & clauses]]]
             (-> query-rec
-                (assoc :group-by (columns->fields query-rec clauses))
+                (assoc :group-by (group-by-entries->fields query-rec clauses))
                 (create-extract-node column nil))
 
             [["extract" column expr]]

    (map->FnExpression (-> fnmap
                           (assoc :statement compiled-fn)))))

(defn alias-columns
  "Alias columns with their fully qualified names, and function expressions
   with the function name."
  [query-rec c]
  (or (get-in query-rec [:projections c :field]) (keyword c)))

(pls/defn-validated columns->fields
  "Convert a list of columns to their true SQL field names."
  [query-rec
   columns]
  (->> columns
       (map #(if (= "function" (first %)) (second %) %))
       (sort-by #(if (string? %) % (:column %)))
       (mapv (partial alias-columns query-rec))))

(pls/defn-validated create-extract-node
  :- {(s/optional-key :projected-fields) [projection-schema]


            [["extract" column expr ["group_by" & clauses]]]
            (-> query-rec
                (assoc :group-by (group-by-entries->fields query-rec clauses))
                (create-extract-node column expr))

            :else nil))
