ShivanshhhG opened a new pull request, #19227:
URL: https://github.com/apache/iceberg/pull/19227
Closes #19219.
## Problem
`JdbcUtil.namespaceExists` checks for child namespaces in
`GET_NAMESPACE_SQL` and `GET_NAMESPACE_PROPERTIES_SQL` using:
```sql
<col> LIKE ? ESCAPE '!'
```
In SQLite, `LIKE` is case-insensitive for ASCII by default, whereas `=` uses
binary (case-sensitive) collation. As a result, when only `sales.eu` exists in
a SQLite-backed `JdbcCatalog`, `namespaceExists(Namespace.of("SALES"))`
returned `true`, allowing strict-mode table creation under `SALES` or failing
`listNamespaces(Namespace.of("SALES"))` inconsistency.
## Fix
Aligned with `apache/iceberg-python#4164`:
- Updated `GET_NAMESPACE_SQL` and `GET_NAMESPACE_PROPERTIES_SQL` in
`JdbcUtil` to verify the child namespace prefix with `SUBSTR(<col>, 1, ?) = ?`
alongside `LIKE ? ESCAPE '!'`.
- Bound the prefix Unicode code-point count as an integer (`setInt`) and the
prefix `<namespace>.` as a string (`setString`), keeping `LIMIT 1` on
`GET_NAMESPACE_SQL` while honoring the column's equality collation across
SQLite, PostgreSQL, MySQL, and MariaDB.
## Validation
- Added `testNamespaceExistsIsCaseSensitiveOnSqlite` and
`testCreateTableInNonExistingParentCaseStrictMode` in `TestJdbcCatalog.java`
covering both `iceberg_namespace_properties` and `iceberg_tables` lookup paths,
`listNamespaces`, and strict-mode table creation.
- Executed `./gradlew :iceberg-core:spotlessCheck
:iceberg-core:checkstyleMain :iceberg-core:checkstyleTest :iceberg-core:test
--tests "org.apache.iceberg.jdbc.*"` (all passed: 312 executed, 30 skipped, 0
failures).
--
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]