codeant-ai-for-open-source[bot] commented on code in PR #45544:
URL: https://github.com/apache/superset/pull/45544#discussion_r4344388525


##########
superset/semantic_layers/execution.py:
##########
@@ -94,14 +94,60 @@ def semantic_namespace() -> str:
     return namespace
 
 
+def metadata_namespace(connection: Connection) -> str:
+    """Read the active metadata store's identity, not the app's startup bind.
+
+    Use the caller's connection without ORM autoflush or another pool checkout.
+    Only a missing identity needs an independent, durable bootstrap 
transaction.
+    Callers memoize this value only within their metadata session.
+    """
+    value: bytes | None = connection.scalar(_namespace_statement())
+    if value is not None:
+        return _decode_namespace(value)
+    if connection.dialect.name == "sqlite" and getattr(
+        connection.connection.driver_connection, "in_transaction", False
+    ):
+        # A separate writer could wait on this caller's SQLite transaction.
+        # Do not commit or roll back caller work to make bootstrap possible.
+        raise ValueError(
+            "Initialize the semantic execution namespace "
+            "before starting a SQLite transaction"
+        )
+    engine: Engine = connection.engine
+    # A separate pool preserves the configured connection creator/on-connect
+    # hooks without waiting for capacity held by this caller in the original 
pool.
+    bootstrap: Engine = Engine(engine.pool.recreate(), engine.dialect, 
engine.url)

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `6095a2e`.
   
   For SQLite engines using `SingletonThreadPool` or `StaticPool`, bootstrap 
now installs the namespace through the existing engine instead of recreating 
the pool, preserving access to the in-memory database.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



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