DG47 opened a new issue, #19219:
URL: https://github.com/apache/iceberg/issues/19219
### Apache Iceberg version
main (development)
### Query engine
None
### Please describe the bug 🐞
`JdbcUtil.namespaceExists` looks for child namespaces with `table_namespace
LIKE '<namespace>.%' ESCAPE '!'` in `GET_NAMESPACE_SQL` (and the same pattern
in `GET_NAMESPACE_PROPERTIES_SQL`) and returns true on the first row. SQLite
evaluates `LIKE` case-insensitively for ASCII, so with only `sales.eu` in a
SQLite-backed `JdbcCatalog`, `namespaceExists(Namespace.of("SALES"))` returns
true, and a table can then be created in `SALES`, which doesn't exist as a
namespace.
PyIceberg's `SqlCatalog` runs the same query and had the same bug
(apache/iceberg-python#4163). apache/iceberg-python#4164 fixes it by also
comparing the prefix in the query, `substr(table_namespace, 1, len + 1) =
'<namespace>.'`, next to the `LIKE`. That keeps `LIMIT 1`, and because it uses
`=`, it follows the same collation as the exact namespace lookups, so on a
case-insensitive collation (MySQL, MariaDB) the existence check still agrees
with the rest of the catalog. I'm opening this so the Java and Python catalogs
stay aligned, as Fokko asked in that review.
I found this by reading `JdbcUtil` on main
(https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/jdbc/JdbcUtil.java,
`GET_NAMESPACE_SQL` and `namespaceExists`). I haven't run it against the Java
catalog.
### Willingness to contribute
- [ ] I can contribute a fix for this bug independently
- [x] I would be willing to contribute a fix for this bug with guidance from
the Iceberg community
- [ ] I cannot contribute a fix for this bug at this time
--
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]