Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/datacustomcode/io/writer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"dockerfile": "../Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/git:1": {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"dockerfile": "../Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/git:1": {}
}
}
8 changes: 5 additions & 3 deletions tests/io/writer/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading