NOT EXISTS clause:where true
{% if is_incremental() %}
and not exists (
select 1
from {{ this }}
where orders.request_id = {{ this }}.request_id
and orders.__metadata_timestamp = {{ this }}.__metadata_timestamp
)
{% endif %}
That simply means:
– take either completely new rows (‘request_id’ does not exist in {{ this }})
– or take ‘request_id’ which exist in {{ this }} but have different __metadata_timestamp (row has been modified)
I thought it was perfect, but Amazon Redshift didn’t think so 😅:
> This type of correlated subquery pattern is not supported due to internal error