Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add a reproduction case for merge failures with struct<string> #2644

Merged
merged 3 commits into from
Jul 3, 2024
Merged
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
2 changes: 1 addition & 1 deletion python/deltalake/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def merge(
target_alias: Optional[str] = None,
error_on_type_mismatch: bool = True,
writer_properties: Optional[WriterProperties] = None,
large_dtypes: bool = True,
large_dtypes: bool = False,
custom_metadata: Optional[Dict[str, str]] = None,
) -> "TableMerger":
"""Pass the source data which you want to merge on the target delta table, providing a
Expand Down
45 changes: 45 additions & 0 deletions python/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,3 +940,48 @@ def test_merge_field_special_characters_delete_2438(tmp_path: pathlib.Path):
expected = pa.table({"x": [1], "y--1": [4]})

assert dt.to_pyarrow_table() == expected


@pytest.mark.pandas
def test_struct_casting(tmp_path: pathlib.Path):
import pandas as pd

cols = ["id", "name", "address", "scores"]
data = [
(
2,
"Marry Doe",
{"street": "123 Main St", "city": "Anytown", "state": "CA"},
[0, 0, 0],
)
]
df = pd.DataFrame(data, columns=cols)
df_merge = pd.DataFrame(
[
(
2,
"Merged",
{"street": "1 Front", "city": "San Francisco", "state": "CA"},
[7, 0, 7],
)
],
columns=cols,
)
assert not df.empty

schema = pa.Table.from_pandas(df=df).schema
dt = DeltaTable.create(tmp_path, schema, name="test")
metadata = dt.metadata()
assert metadata.name == "test"

result = (
dt.merge(
source=df_merge,
predicate="t.id = s.id",
source_alias="s",
target_alias="t",
)
.when_matched_update_all()
.execute()
)
assert result is not None
Loading