Anurag-S1ngh opened a new pull request, #4336:
URL: https://github.com/apache/iceberg-python/pull/4336

   # Rationale for this change
   
   `SqlCatalog.__init__` always built its own engine from the `uri` property, 
and since 0.12 it also probes the catalog schema in the constructor. An 
application that already owns a configured `Engine` could only build the 
catalog from a URI and replace `catalog.engine` afterwards, which is too late: 
the probe has already run on PyIceberg's engine, without the pool, 
`connect_args`, SSL context, event listeners or wait callbacks the application 
set.
   
   `SqlCatalog` now accepts an optional `engine`:
   
   ```python
   catalog = SqlCatalog("default", engine=engine, 
warehouse="s3://bucket/prefix")
   ```
   
   When an engine is passed it is used as-is, `uri` is not required, and 
`_init_catalog()` runs on it, so the schema probe and table creation happen on 
the application's engine. Without an engine the behavior is unchanged: the 
engine is built from `uri` with the existing `echo` and `pool_pre_ping` 
properties.
   
   # Are these changes tested?
   
   Yes, in `tests/catalog/test_sql.py`:
   
   - `test_creation_with_existing_engine` passes an engine, asserts the catalog 
keeps that exact object, asserts the catalog tables were created on it, and 
creates and finds a table.
   - `test_creation_with_existing_engine_without_uri` does the same without a 
`uri` property.
   
   The existing `test_creation_with_no_uri` still covers the error when neither 
an engine nor a URI is given.
   
   Full unit suite: `4562 passed, 5 skipped`. `prek run -a` passes.
   
   # Are there any user-facing changes?
   
   Yes. `SqlCatalog` takes a new optional `engine` argument. When it is given, 
`uri` becomes optional and is only kept in the catalog properties.
   
   Closes #4322
   


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