You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Fabric] get_current_catalog() performs unnecessary DB round-trips in set_current_catalog() #5776
FabricEngineAdapter.set_current_catalog() calls get_current_catalog() twice per invocation — once to guard against a redundant switch, and once to verify the switch succeeded:
defset_current_catalog(self, catalog_name: str) ->None:
current_catalog=self.get_current_catalog() # DB round-trip #1ifcurrent_catalogandcurrent_catalog==catalog_name:
return
...
self._target_catalog=catalog_namecatalog_after_switch=self.get_current_catalog() # DB round-trip #2
get_current_catalog() is inherited from GetCurrentCatalogFromFunctionMixin and executes SELECT db_name() against the database. Because Fabric sessions are stateless, each call opens a new connection and executes a query.
Root Cause
FabricEngineAdapter already maintains _target_catalog as a thread-local attribute that is the authoritative source of truth for what catalog the current thread's connection is pointed at:
Since _target_catalog is always consistent with the catalog used for the next connection, querying the database to determine the current catalog is redundant.
Proposed Fix
Override get_current_catalog() in FabricEngineAdapter to read from _target_catalog directly, falling back to the configured database:
Activity
fresioAS commentedon Apr 29, 2026
#5780