DG47 opened a new pull request, #4164:
URL: https://github.com/apache/iceberg-python/pull/4164

   Closes #4163
   
   # Rationale for this change
   
   `SqlCatalog.namespace_exists` also reports a namespace as existing when a 
child namespace exists, using `LIKE '<namespace>.%'`. SQLite evaluates `LIKE` 
case-insensitively for ASCII characters, so with only `sales.eu` in the 
catalog, `namespace_exists("SALES")` returned True. As a result 
`create_table("SALES.orders")` succeeded in a namespace that does not exist, 
and `create_namespace("SALES")` failed with `NamespaceAlreadyExistsError`. The 
exact-match comparisons elsewhere in the catalog are case-sensitive, and 
PostgreSQL's `LIKE` is case-sensitive too.
   
   This keeps the `LIKE` filter in the query and re-checks the matched 
namespace names with a case-sensitive prefix comparison in Python. 
`list_namespaces` already filters the same way after its `LIKE` query. The 
queries now select only the namespace column with `DISTINCT` instead of whole 
rows with `LIMIT 1`, because a row whose case differs could come back first.
   
   ## Are these changes tested?
   
   Yes. `test_namespace_exists` in `tests/catalog/test_catalog_behaviors.py` 
now also checks that `DB2` and `db3.NS1` are not reported as existing when 
`db2.ns1` and `db3.ns1.ns2` exist. It fails on main for the `memory`, `sql` and 
`sql_without_rowcount` catalogs and passes with this change. `make test` and 
`make lint` pass.
   
   ## Are there any user-facing changes?
   
   On SQLite, `namespace_exists` and the operations that depend on it no longer 
treat a namespace as existing just because a child namespace with a different 
case exists.
   


-- 
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]

Reply via email to