From 0ad6c2c04de55612e922829bdd4f11af9206b83d Mon Sep 17 00:00:00 2001 From: Mark DeLaVergne Date: Thu, 21 May 2026 11:31:58 -0400 Subject: [PATCH 1/3] Remove unsupported OVERWRITE_PARTITIONS write mode --- CHANGELOG.md | 21 +++++++++++++++++++++ src/datacustomcode/io/writer/base.py | 2 +- tests/io/writer/test_csv.py | 8 +++++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85063e1..03b8ca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## 6.0.0 + +### Breaking Changes + +- **`WriteMode.OVERWRITE_PARTITIONS` is deprecated and now raises an error if used.** + + `WriteMode.OVERWRITE_PARTITIONS` remains in the enum for backward compatibility but will raise a `ValueError` at runtime. + + **Migration:** Use `WriteMode.OVERWRITE` to replace all records, or `WriteMode.MERGE` for targeted updates by primary key: + + ```python + # Before + client.write_to_dlo("MyTable__dll", df, write_mode=WriteMode.OVERWRITE_PARTITIONS) + + # After (full replacement) + client.write_to_dlo("MyTable__dll", df, write_mode=WriteMode.OVERWRITE) + + # After (update specific rows by primary key) + client.write_to_dlo("MyTable__dll", df, write_mode=WriteMode.MERGE) + ``` + ## 3.0.0 ### Breaking Changes diff --git a/src/datacustomcode/io/writer/base.py b/src/datacustomcode/io/writer/base.py index e4224f7..6c15eba 100644 --- a/src/datacustomcode/io/writer/base.py +++ b/src/datacustomcode/io/writer/base.py @@ -27,7 +27,7 @@ class WriteMode(str, Enum): APPEND = "append" OVERWRITE = "overwrite" - OVERWRITE_PARTITIONS = "overwrite_partitions" + OVERWRITE_PARTITIONS = "overwrite_partitions" # Deprecated: raises error if used MERGE = "merge" MERGE_UPSERT_DELETE = "merge_upsert_delete" diff --git a/tests/io/writer/test_csv.py b/tests/io/writer/test_csv.py index 4db45cb..0834298 100644 --- a/tests/io/writer/test_csv.py +++ b/tests/io/writer/test_csv.py @@ -37,9 +37,10 @@ def test_write_to_dlo(self, csv_writer, mock_dataframe): test_cases = [ ("test_dlo", WriteMode.OVERWRITE), ("another_dlo", WriteMode.APPEND), - ("third_dlo", WriteMode.OVERWRITE_PARTITIONS), - ("fourth_dlo", WriteMode.MERGE), + ("third_dlo", WriteMode.MERGE), + ("fourth_dlo", WriteMode.MERGE_UPSERT_DELETE), ] + # Note: OVERWRITE_PARTITIONS is deprecated and raises an error if used for name, write_mode in test_cases: # Call the method @@ -58,9 +59,10 @@ def test_write_to_dmo(self, csv_writer, mock_dataframe): test_cases = [ ("test_dmo", WriteMode.OVERWRITE), ("another_dmo", WriteMode.APPEND), - ("third_dmo", WriteMode.OVERWRITE_PARTITIONS), + ("third_dmo", WriteMode.MERGE), ("fourth_dmo", WriteMode.MERGE_UPSERT_DELETE), ] + # Note: OVERWRITE_PARTITIONS is deprecated and raises an error if used for name, write_mode in test_cases: # Call the method From 844389855fa409bbc24a6b8cd272a23fe541b78b Mon Sep 17 00:00:00 2001 From: Mark DeLaVergne Date: Thu, 21 May 2026 16:06:53 -0400 Subject: [PATCH 2/3] Add MERGE_RECORD_TYPE_COLUMN and MergeRecordType for MERGE_UPSERT_DELETE --- src/datacustomcode/io/writer/base.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/datacustomcode/io/writer/base.py b/src/datacustomcode/io/writer/base.py index 6c15eba..d06b1df 100644 --- a/src/datacustomcode/io/writer/base.py +++ b/src/datacustomcode/io/writer/base.py @@ -32,6 +32,16 @@ class WriteMode(str, Enum): MERGE_UPSERT_DELETE = "merge_upsert_delete" +class MergeRecordType(str, Enum): + """Annotation values for the _merge_record_type column required by MERGE_UPSERT_DELETE.""" + + UPSERT = "UPSERT" + DELETE = "DELETE" + + +MERGE_RECORD_TYPE_COLUMN = "_merge_record_type" + + class BaseDataCloudWriter(BaseDataAccessLayer): """Base class for Data Cloud writers.""" From 24cfff14f37a92461d542293b6bb618a6b1dd82a Mon Sep 17 00:00:00 2001 From: Mark DeLaVergne Date: Thu, 21 May 2026 16:52:54 -0400 Subject: [PATCH 3/3] Lint fixes --- src/datacustomcode/io/writer/base.py | 2 +- .../templates/function/.devcontainer/devcontainer.json | 2 +- .../templates/script/.devcontainer/devcontainer.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/datacustomcode/io/writer/base.py b/src/datacustomcode/io/writer/base.py index d06b1df..cb01f76 100644 --- a/src/datacustomcode/io/writer/base.py +++ b/src/datacustomcode/io/writer/base.py @@ -33,7 +33,7 @@ class WriteMode(str, Enum): class MergeRecordType(str, Enum): - """Annotation values for the _merge_record_type column required by MERGE_UPSERT_DELETE.""" + """Values for the _merge_record_type column used by MERGE_UPSERT_DELETE.""" UPSERT = "UPSERT" DELETE = "DELETE" diff --git a/src/datacustomcode/templates/function/.devcontainer/devcontainer.json b/src/datacustomcode/templates/function/.devcontainer/devcontainer.json index 3bdca00..38d8d9a 100644 --- a/src/datacustomcode/templates/function/.devcontainer/devcontainer.json +++ b/src/datacustomcode/templates/function/.devcontainer/devcontainer.json @@ -5,6 +5,6 @@ "dockerfile": "../Dockerfile" }, "features": { - "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers/features/git:1": {} } } diff --git a/src/datacustomcode/templates/script/.devcontainer/devcontainer.json b/src/datacustomcode/templates/script/.devcontainer/devcontainer.json index 3bdca00..38d8d9a 100644 --- a/src/datacustomcode/templates/script/.devcontainer/devcontainer.json +++ b/src/datacustomcode/templates/script/.devcontainer/devcontainer.json @@ -5,6 +5,6 @@ "dockerfile": "../Dockerfile" }, "features": { - "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers/features/git:1": {} } }