Is it possible to write macros in Python instead of Jinja templates ?

Is it possible to write macros in Python instead of Jinja templates And run with run-operation command

Due to the fact that certain operations cannot be imported into the dbt jinja template, including datetime.strptime

{% import "python" as py %} is not working in the macro

`py.datetime.strptime('20211', '%Y%m')`
1 Like

It’s not possible to write arbitrary macros in Python, but the datetime module is exposed to you here: modules | dbt Developer Hub

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.