Relative Content

Tag Archive for jinja2dbt

Manipulate string in DBT’s macro with Jinja2

I am trying to create a dbt macro that can load a table from the macro’s arguments. I can do it when I specify input directly, e.g.: ref('data_categories') (data_categories is a real table name). However, my problem occurs when manipulating the string to pass to ref. Below are my error function and an error during compiling time.

How to insert data into same row using pre-hook and post-hook in dbt?

I am writing a pre hook and a post-hook for my dbt models to create a table with details of my models like execution time etc, what i would like to know is how to ensure that the values are inserted in the same row. i am using insert command in my pre-hook and update command in post-hook. however i am having trouble in adding them to the same row. i cannot use model name as the primary key because i may run each model multiple times. so i created a self incremental column called key which is to be my primary key. so how do i collect the key column value from the pre hook and use it in the post hook?.