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..cb01f76 100644 --- a/src/datacustomcode/io/writer/base.py +++ b/src/datacustomcode/io/writer/base.py @@ -27,11 +27,21 @@ 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" +class MergeRecordType(str, Enum): + """Values for the _merge_record_type column used by MERGE_UPSERT_DELETE.""" + + UPSERT = "UPSERT" + DELETE = "DELETE" + + +MERGE_RECORD_TYPE_COLUMN = "_merge_record_type" + + class BaseDataCloudWriter(BaseDataAccessLayer): """Base class for Data Cloud writers.""" 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": {} } } 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