I'm trying to write a driver for Redis and i am reading thought the docs. The docs mentions a sample driver but it out dated and from v0.35.0 there is new way to implement drivers and it should implement metabase.driver/execute-reducible-query
instead of metabase.driver/execute-query
but the doc is does not cover it. I found a pull request on this change which states
execute-reducible-query
should callreturn-results
with initial results metadata and a object that can be reduced to get resulting rows. Because the driver effectively decorates the reduction process by managing the context in whichreturn-results
is called, it can hold handles to resources (e.g. connections orjava.sql.ResultSet
s) open for the duration of the reduction and close them afterward.
now i don't understand what should be happening here in that pull request there is a sample code
(defmethod driver/execute-reducible-query :my-driver
[_ query chans return-results]
(with-open [results (run-query! query)]
(return-results
{:cols [{:name \"my_col\"}]}
(qp.util.reducible/reducible-rows (get-row results) chans)))
Can someone explain it to me more clearly?
To be more exact what is
An object that can be reduced to get resulting rows.
- What does
qp.util.reducible/reducible-rows
do and how can i implement it myself if i need to?
I've tried to look at other implemented drivers like Mongo and Google analytics but I'm still confused.
Now i need to mention i am totally new to Clojure and basically learning through this project so i really would appreciate your inputs.