This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-13
Channels
- # announcements (1)
- # babashka (2)
- # biff (10)
- # cider (11)
- # clara (17)
- # clerk (10)
- # clojure (21)
- # clojure-berlin (4)
- # clojure-brasil (1)
- # clojure-europe (32)
- # clojure-nl (1)
- # clojure-norway (18)
- # clojure-uk (10)
- # cursive (2)
- # data-science (11)
- # datomic (10)
- # emacs (8)
- # events (7)
- # fulcro (29)
- # gratitude (2)
- # honeysql (21)
- # hyperfiddle (7)
- # lsp (2)
- # malli (4)
- # polylith (4)
- # reitit (8)
- # releases (1)
- # shadow-cljs (15)
- # squint (3)
- # xtdb (5)
Anyone hooked up HoneySQL for use in a https://docs.getdbt.com/ project? I'm thinking something along the lines of writing the models in HoneySQL, compiling them into DBT models as SQL and then letting DBT do the rest. Shouldn't be hard, I'm just wondering if anyone has something going.
If it's regular SQL then there are no show-stoppers. There's no need for any prior art here, you can simply rely on HoneySQL and its docs.
It's almost regular SQL, just with Jinja templating tags involved. Would need to register a HoneySQL fn to create {{ ref('model_name') }}
tags and similar.
Besides that there are a bunch of DBT CLI commands like compile
, run
, etc. that expect SQL files in certain places. I'd like to have it so I only have to touch HoneySQL files and the rest happens seamlessly.
i'm trying to get the :join
https://cljdoc.org/d/com.github.seancorfield/honeysql/2.6.1126/doc/getting-started/sql-special-syntax-#join working but i'm struggling a bit. i want
SELECT *
FROM foo
LEFT JOIN (populations pm INNER JOIN customers pc ON pm.id = pc.id AND pm.other_id = pc.other_id)
ON foo.fk_id = pm.id
I have
(-> (hh/select :*)
(hh/from :foo)
(hh/left-join [[:join [:populations :pm]
(hh/join [:customers :pc]
[:and [:= :pm.id :pc.id]
[:= :pm.other_id :pc.other_id]])]]
[:and [:= :foo.fk_id :pm.id]
[:= :foo.other_fk_id :pm.other_id]])
(sqlv2/format)
(println))
but this produces
[SELECT * FROM "foo" LEFT JOIN JOIN(POPULATIONS("pm"), (INNER JOIN "customers" AS "pc" ON ("pm"."id" = "pc"."id") AND ("pm"."other_id" = "pc"."other_id"))) ON ("foo"."fk_id" = "pm"."id") AND ("foo"."other_fk_id" = "pm"."other_id")]
I can't seem to get the :join
call right such that it correctly nests the initial table and alias
huh, it seems that even the example doesn't work for me:
(sqlv2/format {:join [[[:join :tbl1 {:left-join [:tbl2 [:using :id]]}]]]})
; ["INNER JOIN JOIN(\"tbl1\", (LEFT JOIN \"tbl2\" USING (\"id\")))"]
is this determined by a dialect setting? we're using:
(sqlv2/set-dialect! :ansi :quoted true)
good call, we're using 2.4.1011
. lemme update and see if that fixes it
https://github.com/seancorfield/honeysql/releases/tag/v2.4.1026 there we go, i was one version behind for this
thanks, should have checked the version first
Can't quite achieve what you want because I can only get populations(pm)
and not populations pm
or populations as pm
.
i can work around that, i'm just glad to get the nested join working
just not use an alias in this case
[:join [:raw "populations pm"] ...]
does the trick
not ideal but much nicer than no aliases lol