We have a lot of comments in our Jinja files that show up in the compiled SQL files which makes it difficult to debug the compiled SQL. Also, the whitespace is usually messed up in the compiled SQL files. I understand there is a way to fix whitespacing by modifying the Jinja code but that makes Jinja less readable.
Hence, is there a way to perhaps override the “compile” macro and let it remove the comments and reformat the SQL? Or, is there a way to run some arbitrary script on the compiled SQL post compilation via a hook?
Right, but it’s somewhat less than ideal to go change the entire codebase to incorporate a different style of commenting code.
But anyway, I have created a workaround using a Linux library “inotifywait” to listen for any changes in the target folder, and then running a script that removes all the comments and formats the SQL code.
That’s an interesting point. But it’s somewhat harder because the non-compiled SQL isn’t simply just SQL. It’s as you know Jinja+SQL, for which I don’t have any formatter. Regardless, a simple script could be written to change the comment syntax. But as I said, I am not the most comfortable running that on existing codebase and pushing that as a change. To me it is somewhat unreasonable to change those many lines of “code” for this reason.
Maybe if I have a reliable formatter, I’d be more open to running that on the entire codebase.