'Storing the results from run query into a table in dbt

I am calling this store procedure in dbt. How do I store the results using a select statement into a temp table?

{% set results= run_query('call mystoredproc()') %}
 {% do log("Printing table" , info=True) %}
 {% do results.print_table() %}
 {% set sql %}
 select * from results <<--- how to store the result into  a temp table
{% end set %}  

 {% do run_query(create_table_as(True, tmp_relation, sql)) %}


Solution 1:[1]

You should use the materialization which is a strategy for persisting the dbt models in a warehouse. You can configure the materialization in the project.yml file or configure it directly inside the sql files as:

{{ config(materialized='table | view |', sort='timestamp', dist='user_id') }}

select *
from ...

For more info check the Materialization docs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zoran Pandovski