![](/img/trans.png)
[英]Jinja DBT for loop union with some different columns across tables
[英]How do I loop through alll columns using Jinja in DBT?
我想使用 dbt 遍歷所有列。
我認為 dbt-utils 包中的星形宏 + 一些 for 循環邏輯可能會對您有所幫助? 這取決於您使用的確切用例和倉庫(如評論中所指出的)。
星形宏在提供的表中生成列列表。
因此,一種可能的方法是:
{% for col in [{{ dbt_utils.star(ref('my_model')) }}] %}
...operation...
{% endfor %}
您可以使用內置的adapter
包裝器和adapter.get_columns_in_relation :
{% for col in adapter.get_columns_in_relation(ref('<<your model>>')) -%}
... {{ col.column }} ...
{% endfor %}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.