Skip to content

Commit

Permalink
Pass CommitProperties for custom metadata due to changed api
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Kaufmann committed Mar 5, 2025
1 parent aaa677e commit 32e86e8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion daft/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,18 @@ def write_deltalake(
from daft.io._deltalake import large_dtypes_kwargs
from daft.io.object_store_options import io_config_to_storage_options

# to ensure compatibility for deltalake<0.20
try:
from deltalake import CommitProperties

def _create_custom_metadata(metadata: Optional[Dict[str, str]]):
return CommitProperties(custom_metadata=custom_metadata)

Check warning on line 956 in daft/dataframe/dataframe.py

View check run for this annotation

Codecov / codecov/patch

daft/dataframe/dataframe.py#L955-L956

Added lines #L955 - L956 were not covered by tests
except ImportError:
CommitProperties = None

def _create_custom_metadata(metadata: Optional[Dict[str, str]]):
return metadata

if schema_mode == "merge":
raise ValueError("Schema mode' merge' is not currently supported for write_deltalake.")

Expand Down Expand Up @@ -1093,7 +1105,12 @@ def write_deltalake(
sizes.append(old_actions_dict["size_bytes"][i])

table._table.create_write_transaction(
add_actions, mode, partition_cols or [], delta_schema, None, custom_metadata
add_actions,
mode,
partition_cols or [],
delta_schema,
None,
_create_custom_metadata(custom_metadata),
)
table.update_incremental()

Expand Down

0 comments on commit 32e86e8

Please sign in to comment.