Parameterizing hsql/raw string format

98 views Asked by At

I'm using a product called Metabase and working to get a custom driver working. There's a method I'm overriding that constructs logic getting last X weeks. Below is an example of what I'm trying to accomplish

(defmethod sql.qp/date 
  [:db2 :week] 
  [_ _ expr] 
  (hx/- expr 
    (hsql/raw 
      (hsql/format "days" (hsql/call :dayofweek expr)))))

expr here equates to this: (CAST(current timestamp AS timestamp) + -14 days)

When my code above runs, I get this output:

((CAST(current timestamp AS timestamp) + -14 days) - ? days)

My desired output here is:

((CAST(current timestamp AS timestamp) + -14 days) - dayofweek((CAST(current timestamp AS timestamp) + -14 days)) days)

I'm extremely new to clojure and fumbling my way through this. Any advice or help would be greatly appreciated!

Thanks!

0

There are 0 answers