You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm using sqlfmt as it is the best SQL formatter I found, to apply it on the Snowflake SQL dialect, but unfortunately a lot of commands such as this CREATE TABLE AS ... seems not supported yet.
Do you think I can help you solving this? And in the meantime, would you recommend a workaround to make sqlfmt still format the rest of the query?
@mlemainque Thanks for your feedback and offer to contribute.
Unfortunately adding new commands like this requires changing lexing rules, which gets complex fast. I can point you to this PR, which implements (snowflake's) create ... clone statement, which is quite a bit simpler than CTAS.
I think it's likely that the implementation for CTAS will be closely related to supporting all create table statements (#300), and I don't know when I'll get around to that -- to be transparent this isn't my highest priority at the moment.
As for a workaround, for safety reasons, sqlfmt interprets create table as a FMT_OFF token, identical to the tokens we use to lex --fmt: off comments. This means you can use a --fmt: on comment to reactivate formatting. In other words this:
https://www.postgresql.org/docs/current/sql-createtableas.html
The text was updated successfully, but these errors were encountered: