From 220054dc99c0c09c869fea29150e6a34813b845c Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Thu, 29 Feb 2024 07:53:33 -0800 Subject: [PATCH] show key when none --- pyiceberg/types.py | 4 ++-- tests/catalog/test_base.py | 2 +- tests/catalog/test_sql.py | 2 +- tests/integration/test_writes.py | 2 +- tests/table/test_init.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyiceberg/types.py b/pyiceberg/types.py index a87ccd6a42..746f03ea0b 100644 --- a/pyiceberg/types.py +++ b/pyiceberg/types.py @@ -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()} diff --git a/tests/catalog/test_base.py b/tests/catalog/test_base.py index 78b45c55d9..c7d3f01ff1 100644 --- a/tests/catalog/test_base.py +++ b/tests/catalog/test_base.py @@ -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) diff --git a/tests/catalog/test_sql.py b/tests/catalog/test_sql.py index 5ebd7dcbd5..0b869d6826 100644 --- a/tests/catalog/test_sql.py +++ b/tests/catalog/test_sql.py @@ -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) diff --git a/tests/integration/test_writes.py b/tests/integration/test_writes.py index edc7a63e09..1eeec2b3f7 100644 --- a/tests/integration/test_writes.py +++ b/tests/integration/test_writes.py @@ -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) diff --git a/tests/table/test_init.py b/tests/table/test_init.py index 9765245a20..04efc5f402 100644 --- a/tests/table/test_init.py +++ b/tests/table/test_init.py @@ -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)