From f3c1fe511000393270184d22006d90db73ff6861 Mon Sep 17 00:00:00 2001 From: BernardWez Date: Fri, 24 Nov 2023 09:50:38 +0100 Subject: [PATCH] Small refactor `set_replication_keys` method --- elx/catalog.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/elx/catalog.py b/elx/catalog.py index 3706eb3..b1be63b 100644 --- a/elx/catalog.py +++ b/elx/catalog.py @@ -180,22 +180,21 @@ def set_replication_keys(self, replication_keys: Optional[dict]) -> "Catalog": # Set the replication method to INCREMENTAL stream.replication_method = "INCREMENTAL" + # The replication key for current stream + replication_key = replication_keys[stream.tap_stream_id] + # Update the replication key value - stream.replication_key = replication_keys[stream.tap_stream_id] + stream.replication_key = replication_key # Add the replication key to stream metadata stream.upsert_metadata( breadcrumb=[], - metadata={ - "valid-replication-keys": [ - replication_keys[stream.tap_stream_id] - ] - }, + metadata={"valid-replication-keys": [replication_key]}, ) # Set inclusion of replication property metadata to `automatic` stream.upsert_metadata( - breadcrumb=["properties", replication_keys[stream.tap_stream_id]], + breadcrumb=["properties", replication_key], metadata={"inclusion": "automatic"}, )