Skip to content

Commit

Permalink
show key when none
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjqliu committed Feb 29, 2024
1 parent 546262e commit 220054d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pyiceberg/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@

def transform_dict_value_to_str(dict: Dict[str, Any]) -> Dict[str, str]:
"""Transform all values in the dictionary to string. Raise an error if any value is None."""
for value in dict.values():
for key, value in dict.items():
if value is None:
raise ValueError("None type is not a supported value in properties")
raise ValueError(f"None type is not a supported value in properties: {key}")
return {k: str(v) for k, v in dict.items()}


Expand Down
2 changes: 1 addition & 1 deletion tests/catalog/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,4 +678,4 @@ def test_table_properties_raise_for_none_value(catalog: InMemoryCatalog) -> None
property_with_none = {"property_name": None}
with pytest.raises(ValidationError) as exc_info:
_ = given_catalog_has_a_table(catalog, properties=property_with_none)
assert "None type is not a supported value in properties" in str(exc_info.value)
assert "None type is not a supported value in properties: property_name" in str(exc_info.value)
2 changes: 1 addition & 1 deletion tests/catalog/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,4 +951,4 @@ def test_table_properties_raise_for_none_value(
property_with_none = {"property_name": None}
with pytest.raises(ValidationError) as exc_info:
_ = catalog.create_table(random_identifier, table_schema_simple, properties=property_with_none)
assert "None type is not a supported value in properties" in str(exc_info.value)
assert "None type is not a supported value in properties: property_name" in str(exc_info.value)
2 changes: 1 addition & 1 deletion tests/integration/test_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,4 +688,4 @@ def test_table_properties_raise_for_none_value(
_ = _create_table(
session_catalog, identifier, {"format-version": format_version, **property_with_none}, [arrow_table_with_null]
)
assert "None type is not a supported value in properties" in str(exc_info.value)
assert "None type is not a supported value in properties: property_name" in str(exc_info.value)
2 changes: 1 addition & 1 deletion tests/table/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,4 +1107,4 @@ def test_table_properties_raise_for_none_value(example_table_metadata_v2: Dict[s
example_table_metadata_v2 = {**example_table_metadata_v2, "properties": property_with_none}
with pytest.raises(ValidationError) as exc_info:
TableMetadataV2(**example_table_metadata_v2)
assert "None type is not a supported value in properties" in str(exc_info.value)
assert "None type is not a supported value in properties: property_name" in str(exc_info.value)

0 comments on commit 220054d

Please sign in to comment.