我们如何在 SCD 1 实现的增量模型中使用合并语句

How do we use the merge statement inside Incremental model for SCD 1 Implementation

我正在尝试使用合并查询在数据构建工具中实现 scd1。但是我没有得到在增量模型中编写此查询的确切方法。

任何人都可以告诉我们必须在哪里编写合并查询。

{{
    config(
        materialized='incremental'
    )
}}

<MERGE QUERY HERE> 

{% if is_incremental() %}
where last_modified_date > '2020-07-11'
{% endif %}

您实际上不需要编写合并语句,dbt 会为您处理。您应该编写一个查询,将 return 您要插入的记录。然后您可以检查 dbt 生成的合并查询的日志。

另请查看有关配置增量模型的 dbt 文档:https://docs.getdbt.com/docs/building-a-dbt-project/building-models/configuring-incremental-models#what-is-an-incremental_strategy