danhuawang opened a new issue, #11285:
URL: https://github.com/apache/gravitino/issues/11285

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   When using the JDBC catalog backend, the `POST 
/v1/namespaces/{namespace}/tables` endpoint allows creating a table in a 
namespace that does not exist. According to the Iceberg REST catalog 
specification, this should return HTTP 404 (`NoSuchNamespaceError`).
   
   The memory catalog backend correctly rejects this request with a 404, but 
the JDBC backend implicitly creates the namespace and successfully creates the 
table.
   
   ### Error message and/or stacktrace
   
   No error is raised — that is the problem. The test expects a 
`NoSuchNamespaceError` but the operation succeeds:
   
   ```
   FAILED test_create_table_with_invalid_database[rest_catalog] - Failed: DID 
NOT RAISE <class 'pyiceberg.exceptions.NoSuchNamespaceError'>
   ```
   
   ### How to reproduce
   
   1. Start Gravitino Iceberg REST server with JDBC catalog backend (e.g., 
SQLite or H2):
   
   ```properties
   gravitino.iceberg-rest.catalog-backend = jdbc
   gravitino.iceberg-rest.uri = jdbc:sqlite::memory:
   gravitino.iceberg-rest.jdbc-driver = org.sqlite.JDBC
   gravitino.iceberg-rest.warehouse = s3://warehouse/
   ```
   
   2. Attempt to create a table in a namespace that does not exist:
   
   ```bash
   # Verify namespace does not exist
   curl http://localhost:8181/iceberg/v1/namespaces/invalid
   # Should return 404
   
   # Create table in non-existent namespace
   curl -X POST http://localhost:8181/iceberg/v1/namespaces/invalid/tables \
     -H "Content-Type: application/json" \
     -d '{"name": "test_table", "schema": {"type": "struct", "fields": [{"id": 
1, "name": "id", "type": "long", "required": false}]}}'
   # Expected: 404 NoSuchNamespaceError
   # Actual: 200 OK (table created, namespace implicitly created)
   ```
   
   3. Alternatively, reproduce with pyiceberg:
   
   ```python
   from pyiceberg.catalog.rest import RestCatalog
   
   catalog = RestCatalog("rest", **{
       "uri": "http://localhost:8181/iceberg/";,
       "auth": {"type": "noop"},
   })
   
   # This should raise NoSuchNamespaceError but succeeds
   table = catalog.create_table(
       ("invalid", "test_table"),
       schema=...,
   )
   ```
   
   ### Additional context
   
   - The memory catalog backend (`gravitino.iceberg-rest.catalog-backend = 
memory`) correctly returns 404 for this case.
   - This behavior violates the Iceberg REST catalog specification which states 
that `POST /v1/namespaces/{namespace}/tables` should return 404 if the 
namespace does not exist.
   - The JDBC backend appears to implicitly create namespaces when creating 
tables, which can lead to unexpected namespace proliferation and makes it 
impossible for clients to detect typos in namespace names.
   


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

Reply via email to