Skip to content

Commit

Permalink
issue #904. Err when no props in metadata (#905)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Durant <[email protected]>
  • Loading branch information
remi-sap and martindurant authored Nov 20, 2023
1 parent cea4afe commit 282c2de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fastparquet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,18 @@ def update_custom_metadata(obj, custom_metadata : dict):
Thrift object or parquet file which metadata is to update.
custom_metadata : dict
Key-value metadata to update in thrift object.
The values must be strings or binary. To pass a dictionary, serialize it as json string then encode it in binary.
Notes
-----
Key-value metadata are expected binary encoded. This function ensures it
is.
"""
kvm = (obj.key_value_metadata if isinstance(obj, ThriftObject)
else obj.fmd.key_value_metadata)

if kvm is None:
kvm = []

# Spare list of keys.
kvm_keys = [item.key for item in kvm]
for key, value in custom_metadata.items():
Expand Down
1 change: 1 addition & 0 deletions fastparquet/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,7 @@ def update_file_custom_metadata(path: str, custom_metadata: dict,
Local path to file.
custom_metadata : dict
Key-value metadata to update in thrift object.
The values must be strings or binary. To pass a dictionary, serialize it as json string then encode it in binary.
is_metadata_file : bool, default None
Define if target file is a pure metadata file, or is a parquet data
file. If `None`, is set depending file name.
Expand Down

0 comments on commit 282c2de

Please sign in to comment.