Fork me on GitHub
#honeysql
<
2022-03-21
>
Nick Stares22:03:03

Hello, I'm trying to generate the following (postgres)SQL with honeysql:

CREATE TEMPORARY TABLE temp_table AS
            TABLE display_impressions_reach_by_line_test
            WITH NO DATA;
I've been playing around with argument orderings to create-table-as but no luck
(-> {:create-table-as [:temporary :table :temp_table :display_impressions_reach_by_line_test]}
    sql/format)
;; => ["CREATE TEMPORARY TABLE TEMP_TABLE TABLE display_impressions_reach_by_line_test AS"]
I can't figure out how I'm supposed to order the symbols in the argument vector

seancorfield16:03:24

Can you open a Github issue with details so I can take a look at the exact syntax and what needs to be done? I'm not sure right now whether what you're asking for can be done directly in HoneySQL or whether some enhancements are required. Thanks, @U8STBJZU0

❤️ 1
dharrigan21:03:48

Should I add this as a ticket? It hasn't been added yet, so happy to just do that 🙂

seancorfield21:03:37

@U11EL3P9U Thanks! Yes, please. Thanks for the returning doc ticket, BTW.

dharrigan21:03:49

you're most welcome. I'll just copy pasta above into a ticket.

seancorfield22:03:45

It took me a while to figure out what that SQL syntax was meant to be -- and then I discovered that PostgreSQL has a TABLE command that is equivalent to SELECT * FROM and then it made more sense:

dev=> (println (sql/format {:create-table-as [:temporary :temp_table] :select :* :from :display_impressions_reach_by_line_test :with-data false} {:pretty true}))
[
CREATE TEMPORARY TABLE temp_table AS
SELECT *
FROM display_impressions_reach_by_line_test
WITH NO DATA
]

seancorfield22:03:43

HoneySQL doesn't support a :table clause right now so that select/from is the best you can do.

seancorfield15:03:35

I've added :table as a clause (on develop) for the next release - see that issue.