将运行查询的结果存储到DBT中的表中
我在 dbt 中调用这个存储过程。如何使用 select 语句将结果存储到临时表中?
{% 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)) %}
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)) %}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用实体化,这是持续仓库中DBT模型的策略。您可以在project.yml文件中配置实现化或直接在sql文件中配置它的内容:
有关更多信息,请访问“物化文档” 。
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:
For more info check the Materialization docs.
当我尝试创建一个稍后可以加入同一模型的表时,我遇到了这个问题。结果我需要做的就是:
I ran into this problem when trying to create a table that I could join later on in the same model. Turned out all I needed to do was: