Fokko commented on code in PR #4464:
URL: https://github.com/apache/iceberg-python/pull/4464#discussion_r4706414174


##########
pyiceberg/catalog/memory.py:
##########
@@ -26,8 +29,10 @@ class InMemoryCatalog(SqlCatalog):
     This is useful for test, demo, and playground but not in production as it 
does not support concurrent access.
     """
 
-    def __init__(self, name: str, warehouse: str = 
"file:///tmp/iceberg/warehouse", **kwargs: str) -> None:
+    def __init__(
+        self, name: str, warehouse: str = "file:///tmp/iceberg/warehouse", 
engine: Engine | None = None, **kwargs: str
+    ) -> None:
         self._warehouse_location = warehouse
-        if URI not in kwargs:
-            kwargs[URI] = "sqlite:///:memory:"
-        super().__init__(name=name, warehouse=warehouse, **kwargs)
+        if engine is None and URI not in kwargs:
+            engine = create_engine("sqlite://", poolclass=StaticPool, 
connect_args={"check_same_thread": False})

Review Comment:
   `echo` and `pool_pre_ping` used to reach the engine through `SqlCatalog`, 
but now that the engine is built here they're dropped. Something like this 
keeps them:
   
   ```suggestion
           if engine is None and URI not in kwargs:
               echo_str = str(kwargs.get("echo", DEFAULT_ECHO_VALUE)).lower()
               engine = create_engine(
                   "sqlite://",
                   echo=strtobool(echo_str) if echo_str != "debug" else "debug",
                   pool_pre_ping=strtobool(kwargs.get("pool_pre_ping", 
DEFAULT_POOL_PRE_PING_VALUE)),
                   poolclass=StaticPool,
                   connect_args={"check_same_thread": False},
               )
   ```
   
   This needs `DEFAULT_ECHO_VALUE` and `DEFAULT_POOL_PRE_PING_VALUE` from 
`pyiceberg.catalog.sql`, and `strtobool` from `pyiceberg.types`.
   



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