                       (jdbc/with-db-connection db
                         (jdbc/with-db-transaction []
                           (let [{:keys [results-query count-query]}
-                                (query->sql query entity version query-options
-                                            {:log-id log-id})
+                                (query->sql query entity version query-options context)
                                 st (when count-query
                                      {:count (jdbc/get-result-count count-query)})
                                 stream-row (fn [row]


(defn- deprecated-produce-streaming-body
  [version query-map context]
  (let [{:keys [scf-read-db url-prefix warn-experimental pretty-print log-queries]
         :or {warn-experimental true}} context
        log-id (when log-queries (str (java.util.UUID/randomUUID)))
        query-config (select-keys context [:node-purge-ttl :add-agent-report-filter])
        {:keys [query remaining-query entity query-options]}
        (user-query->engine-query version query-map query-config warn-experimental)]

      ;; Log origin and AST of incoming query
      (let [{:keys [origin query]} query-map]
        (log/infof "PDBQuery:%s:%s"
                   query-id (-> (sorted-map :origin origin :ast query)
                                json/generate-string))))

    (try
      (jdbc/with-transacted-connection scf-read-db
        (let [munge-fn (get-munge-fn entity version query-options url-prefix)
              {:keys [results-query count-query]}
              (-> remaining-query
                  coerce-from-json
                  (query->sql entity version query-options
                              (select-keys context [:log-queries :query-id])))
              query-error (promise)
              resp (http/streamed-response
                    buffer
