                          [field-id "ascending"]))
                  (apply conj (or order-by-subclauses []))
                  (assoc query :order_by)))))
+
+
+;;; ### ADD-IMPLICIT-LIMIT
+
+(defn add-implicit-limit
+  "Add an implicit limit clause to queries with `rows` aggregations."
+  [{:keys [limit aggregation] :as query}]
+  (if (and (= aggregation ["rows"])
+           (not limit))
+    (assoc query :limit max-result-rows)
+    query))
 
 
 ;; ### PREPROCESS-CUMULATIVE-SUM

            [metabase.models.field :refer [Field field->fk-table]]))

(declare add-implicit-breakout-order-by
         get-special-column-info
         preprocess-cumulative-sum
         preprocess-structured

         (sequential? (:columns results))
         (sequential? (:cols results))
         (sequential? (:rows results))]}
  (let [num-results (count (:rows results))]
    (cond-> {:row_count (count (:rows results))
             :status    :completed
             :data      results}
      (= num-results max-result-rows) (assoc :num_results_over_limit true)))) ; so the front-end can let the user know why they're being arbitarily limited

;; ### POST-PROCESS

