diff --git a/pyiceberg/catalog/dynamodb.py b/pyiceberg/catalog/dynamodb.py index 74c0be6c9a..ee0e5e23de 100644 --- a/pyiceberg/catalog/dynamodb.py +++ b/pyiceberg/catalog/dynamodb.py @@ -891,4 +891,4 @@ def _add_property_prefix(prop: str) -> str: def _remove_property_prefix(prop: str) -> str: - return prop.lstrip(PROPERTY_KEY_PREFIX) + return prop.removeprefix(PROPERTY_KEY_PREFIX) diff --git a/tests/catalog/test_dynamodb.py b/tests/catalog/test_dynamodb.py index 5933e7d472..97ee824812 100644 --- a/tests/catalog/test_dynamodb.py +++ b/tests/catalog/test_dynamodb.py @@ -502,6 +502,26 @@ def test_load_namespace_properties(_bucket_initialize: None, database_name: str) assert v == test_properties[k] +@mock_aws +def test_load_namespace_properties_with_prefix_char_keys(_bucket_initialize: None, database_name: str) -> None: + # Property keys starting with a character in the "p." prefix (e.g. "p" or ".") must + # survive a round trip. The stored keys are prefixed with PROPERTY_KEY_PREFIX ("p."), + # so decoding must strip only that literal prefix, not any leading "p"/"." characters. + test_properties = { + "provider": "s3", + "path": f"s3://{BUCKET_NAME}/{database_name}.db", + "ppp": "3", + ".hidden": "yes", + "comment": "not affected", + } + test_catalog = DynamoDbCatalog("test_ddb_catalog") + test_catalog.create_namespace(database_name, test_properties) + listed_properties = test_catalog.load_namespace_properties(database_name) + for k, v in test_properties.items(): + assert k in listed_properties + assert listed_properties[k] == v + + @mock_aws def test_load_non_exist_namespace_properties(_bucket_initialize: None, database_name: str) -> None: test_catalog = DynamoDbCatalog("test_ddb_catalog")