Commit 7209466 1 parent f36aa55 commit 7209466 Copy full SHA for 7209466
File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 623
623
624
624
625
625
(defn calculate-aggregate
626
- [tuples aggregate-fn-map]
626
+ [{ :keys [headers vars tuples]} aggregate-fn-map]
627
627
(let [{:keys [variable as function]} aggregate-fn-map
628
- agg-params (flatten (select-from-tuples [variable] tuples))
629
- agg-result (function agg-params)]
628
+ var (or (as-variable variable)
629
+ (:variable variable))
630
+ value (if-let [var-idx (util/index-of headers var)]
631
+ (map #(nth % var-idx) tuples)
632
+ (if-let [val (get vars var)]
633
+ (map (constantly val) tuples)
634
+ (throw (ex-info (str " Invalid aggregate variable:" var)
635
+ {:status 400 :error :db/invalid-query }))))
636
+ agg-result (function value)]
630
637
[as agg-result]))
631
638
632
639
(defn add-aggregate-cols
You can’t perform that action at this time.
0 commit comments