Ability to write to files with Jinja #5100
Replies: 1 comment
-
Hmm. Hmm! I'm not sure if or how we could realistically support this. I so appreciate you opening the issue and starting the conversation, @randypitcherii. Today, dbt does write to files, with Jinja, sort of: It compiles Jinja templates, from files, and writes them to other files (in the All that said...
This is compelling, I buy it, and I know there are limitations to the two ways of working around this today. The bash-y wayLeveraging the fact that dbt/Jinja can write anything its heart desires to stdout, pipe the stdout contents somewhere else.
Limitations:
The file-based wayStick each macro in a SQL file in the Limitations:
At some point, I'm so on board with the request—I'm just not sure if dbt Core can be the right tool for the job, or it's a better fit for a helper tool written in python. |
Beta Was this translation helpful? Give feedback.
-
Describe the feature
As a user, I would like a Jinja context built-in function similar to print that allows me to write to files.
Describe alternatives you've considered
Today I largely print generated code to stdout.
Who will this benefit?
The use case I have in mind is to allow the results of the codegen package to actually persist generated code to dbt yaml files directly.
Are you interested in contributing this feature?
Yes!
Beta Was this translation helpful? Give feedback.
All reactions