Skip to content
Snippets Groups Projects
Commit 8a04ad57 authored by Michael Beer's avatar Michael Beer Committed by Philipp Bogensberger
Browse files

removed between filter since this is released with Crate 0.57

parent 9855e2c1
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,7 @@
[clojure.set :as set]
[honeysql.core :as hsql]
[metabase.driver :as driver]
(metabase.driver.crate [query-processor :as qp]
[util :as crate-util])
[metabase.driver.crate.util :as crate-util]
[metabase.driver.generic-sql :as sql]
[metabase.util :as u]))
......@@ -77,7 +76,6 @@
{:connection-details->spec (u/drop-first-arg crate-spec)
:column->base-type (u/drop-first-arg column->base-type)
:string-length-fn (u/drop-first-arg string-length-fn)
:apply-filter qp/apply-filter
:date crate-util/date
:unix-timestamp->timestamp crate-util/unix-timestamp->timestamp
:current-datetime-fn (constantly now)}))
......
(ns metabase.driver.crate.query-processor
(:require [honeysql.helpers :as h]
[metabase.driver.generic-sql.query-processor :as qp]
[metabase.query-processor.interface :as i]))
(defn- rewrite-between
"Rewrite [:between <field> <min> <max>] -> [:and [:>= <field> <min>] [:<= <field> <max>]]"
[clause]
(i/strict-map->CompoundFilter {:compound-type :and
:subclauses [(i/strict-map->ComparisonFilter {:filter-type :>=
:field (:field clause)
:value (:min-val clause)})
(i/strict-map->ComparisonFilter {:filter-type :<=
:field (:field clause)
:value (:max-val clause)})]}))
(defn- filter-clause->predicate
"resolve filters recursively"
[{:keys [compound-type filter-type subclause subclauses], :as clause}]
(case compound-type
:and (apply vector :and (map filter-clause->predicate subclauses))
:or (apply vector :or (map filter-clause->predicate subclauses))
:not [:not (filter-clause->predicate subclause)]
nil (qp/filter-clause->predicate (if (= filter-type :between)
(rewrite-between clause)
clause))))
(defn apply-filter
"Apply custom generic SQL filter. This is the place to perform query rewrites."
[_ honeysql-form {clause :filter}]
(h/where honeysql-form (filter-clause->predicate clause)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment