hello!
I’m using
{{
config(
materialized='incremental',
unique_key='id',
merge_update_columns = ['phone', 'created_at']
)
}}
but I want to update record only if changes occured in “phone” column.
for now I do it like this but it feels a bit wierd:
{{
config(
materialized='incremental',
unique_key='id',
merge_update_columns = ['phone', 'created_at']
)
}}
WITH source_data AS (
SELECT
id,
first_name AS name,
phone,
created_at
FROM costumers_dbt_examples
)
SELECT
id,
name,
phone,
created_at
FROM source_data
{% if is_incremental() %}
WHERE id IN (
SELECT id
FROM {{ this }}
WHERE source_data.phone != {{ this }}.phone
)
OR id NOT IN (
SELECT id FROM {{ this }}
)
{% endif %}
Is there a built in feature in dbt that will allow me to choose which columns in source table to look for changes in?
thanks alot!