inserting dbt execution message in snowfake log table

16 Views Asked by At

I am excuting my models on daily basis and wants to keep log of its execution in a snowflake model for report purpose. I used result object to read information of executions like name ,status,rows_affected,execution_time. Along with this I want to save "Message" from result in my table. I am currently taking result object as dictionary and while fetching message, I use below: {% set node1 = tojson(run_result_dict.get('message',{})) %} but when there is an error like Database Error in model dim_customerfile (models\customer.sql) 000904 (42000): SQL compilation error: error line 126 at position 2 invalid identifier 'CC.name1' I am unable to insert it in my table using simple insert statement.

I tried using replace

  insert into  execution_log(err_message) 
values(
 replace(replace("Database Error in model dim_customerfile (models\customer.sql)
  000904 (42000): SQL compilation error: error line 126 at position 2
  invalid identifier 'CC.name1'",'\'', ''''),'\'')
 )

but its giving error for

Error: invalid identifier '"Database Error in model dim_customerfile (models\customer.sql)

0

There are 0 best solutions below