Complete the code to check if the model is running incrementally.
SELECT * FROM {{ source('my_schema', 'my_table') }} WHERE [1]is_full_refresh() instead, which checks for full refresh runs.is_snapshot() with incremental runs.The is_incremental() macro returns true when the model runs incrementally.
Complete the code to add a filter only when running incrementally.
SELECT * FROM {{ ref('my_model') }} WHERE [1] AND updated_at > (SELECT MAX(updated_at) FROM {{ this }})is_full_refresh() which is true during full refreshes, not incremental runs.The filter should apply only during incremental runs, so is_incremental() is used.
Fix the error in the code to correctly check for incremental runs.
{% if [1] %} SELECT * FROM source_table {% else %} SELECT * FROM full_table {% endif %}The macro is_incremental() must be called with parentheses to execute properly.
Fill both blanks to add a condition that runs only during incremental loads and filters new records.
SELECT * FROM {{ ref('orders') }} WHERE {% if [1] %} order_date > (SELECT MAX(order_date) FROM [2]) {% else %} TRUE {% endif %}is_full_refresh() instead of is_incremental().ref() macro.Use is_incremental() to check incremental run and ref('orders') to refer to the current model.
Fill all three blanks to create an incremental model that inserts only new records based on id and updated_at.
WITH new_data AS ( SELECT * FROM {{ ref('source_data') }} ), filtered_data AS ( SELECT * FROM new_data WHERE {% if [1] %} updated_at > ( SELECT MAX(updated_at) FROM [2] ) {% else %} TRUE {% endif %} ) SELECT * FROM [3]ref('source_data') instead of this for existing data.new_data instead of filtered_data.Use is_incremental() to check incremental run, this to refer to the current model table, and select from filtered_data to output new records.