From 989376767f94743592f5985c0f4111e20355680e Mon Sep 17 00:00:00 2001 From: Tom Wier Date: Tue, 11 Feb 2025 11:35:43 +0300 Subject: [PATCH] fix(#156): moving condition outside incremental --- models/root/document_metadata.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/models/root/document_metadata.sql b/models/root/document_metadata.sql index 17a30065..e54f7402 100644 --- a/models/root/document_metadata.sql +++ b/models/root/document_metadata.sql @@ -22,10 +22,9 @@ from {{ source('couchdb', env_var('POSTGRES_TABLE')) }} source_table {% if is_incremental() %} WHERE source_table.saved_timestamp >= {{ max_existing_timestamp('saved_timestamp') }} +{% endif %} - {% if var("batch_size") is not none %} - ORDER BY saved_timestamp - LIMIT {{ var('batch_size') }} - {% endif %} - +{% if var("batch_size") is not none %} + ORDER BY saved_timestamp + LIMIT {{ var('batch_size') }} {% endif %}