Shahzeb-DataEngineer opened a new pull request, #4168:
URL: https://github.com/apache/iceberg-python/pull/4168
## Description
`SqlCatalog.namespace_exists` used a `LIKE` prefix check to detect parent
namespaces. SQLite evaluates `LIKE` case-insensitively for ASCII, so with only
`sales.eu` stored, `namespace_exists("SALES")` returned `True`, while the
exact-match lookups in the same catalog and PostgreSQL (where `LIKE` is
case-sensitive) said otherwise. That inconsistency leaked into `create_table`,
`create_namespace`, and `load_namespace_properties`, which all go through
`namespace_exists`.
This PR replaces the `LIKE` prefix check with a `substr` prefix comparison,
which is case-sensitive on both SQLite and PostgreSQL, in both the tables and
the namespace-properties queries. It also removes the need for the `LIKE`
pattern escaping. `list_namespaces` is unchanged: it already filters fuzzy
matches in Python with exact tuple equality.
## Related Issue
Closes #4163
## Testing
- Reproduced the reported case on SQLite before the fix
(`namespace_exists("SALES")` was `True`, `create_namespace("SALES")` raised
`NamespaceAlreadyExistsError`) and verified all of it is fixed after.
- New regression test `test_namespace_exists_is_case_sensitive` in
`tests/catalog/test_sql.py`, plus edge cases verified manually (namespaces
containing `%`/`_` no longer risk pattern-matching surprises).
- `tests/catalog/test_sql.py`: 25 passed. `ruff check` and `ruff format
--check` clean on both touched files.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]