Skip to content

Commit f3d07c2

Browse files
committed
fix: add regression test for working with dotted-named columns in Python
Somewhere along the line, our handling of this behavior improved, so this issue is resolved Closes #2624 Signed-off-by: R. Tyler Croy <[email protected]>
1 parent fae52d6 commit f3d07c2

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

python/deltalake/writer/writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def write_deltalake(
9797
configuration: A map containing configuration options for the metadata action.
9898
schema_mode: If set to "overwrite", allows replacing the schema of the table. Set to "merge" to merge with existing schema.
9999
storage_options: options passed to the native delta filesystem.
100-
predicate: When using `Overwrite` mode, replace data that matches a predicate. Only used in rust engine.'
100+
predicate: When using `Overwrite` mode, replace data that matches a predicate.'
101101
target_file_size: Override for target file size for data files written to the delta table. If not passed, it's taken from `delta.targetFileSize`.
102102
writer_properties: Pass writer properties to the Rust parquet writer.
103103
post_commithook_properties: properties for the post commit hook. If None, default values are used.

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ignore = ["E501", "ANN401", "RUF040"]
7070
known-first-party = ["deltalake"]
7171

7272
[tool.pytest.ini_options]
73-
addopts = "-v -m 'not integration and not benchmark and not no_pyarrow'"
73+
addopts = "-v -x -m 'not integration and not benchmark and not no_pyarrow'"
7474
testpaths = ["tests", "deltalake"]
7575
markers = [
7676
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')",

python/tests/test_writer.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,3 +2510,49 @@ def test_tilde_path_works_with_writes():
25102510
expanded_path = os.path.expanduser(tilde_path)
25112511
if os.path.exists(expanded_path):
25122512
shutil.rmtree(expanded_path)
2513+
2514+
2515+
@pytest.mark.pyarrow
2516+
def test_dots_in_column_names_2624(tmp_path: pathlib.Path):
2517+
"""
2518+
<https://github.com/delta-io/delta-rs/issues/2624>
2519+
"""
2520+
import pyarrow as pa
2521+
initial = pa.Table.from_pydict(
2522+
{
2523+
"Product.Id": ['x-0', 'x-1', 'x-2', 'x-3'],
2524+
'Cost' : [10, 11, 12, 13],
2525+
}
2526+
)
2527+
2528+
write_deltalake(
2529+
table_or_uri=tmp_path,
2530+
data=initial,
2531+
partition_by=["Product.Id"],
2532+
)
2533+
2534+
update = pa.Table.from_pydict(
2535+
{
2536+
"Product.Id": ['x-1'],
2537+
'Cost' : [101],
2538+
}
2539+
)
2540+
2541+
write_deltalake(
2542+
table_or_uri=tmp_path,
2543+
data=update,
2544+
partition_by=["Product.Id"],
2545+
mode="overwrite",
2546+
predicate="\"Product.Id\" = 'x-1'"
2547+
)
2548+
2549+
dt = DeltaTable(tmp_path)
2550+
expected = pa.Table.from_pydict(
2551+
{
2552+
"Product.Id": ['x-0', 'x-1', 'x-2', 'x-3'],
2553+
'Cost' : [10, 101, 12, 13],
2554+
}
2555+
)
2556+
# Sorting just to make sure the equivalency matches up
2557+
actual = dt.to_pyarrow_table().sort_by('Product.Id')
2558+
assert expected == actual

0 commit comments

Comments
 (0)