Fix(Fabric): Skip Catalog Jump#5780
Conversation
72116e9 to
9e7ee51
Compare
|
@fresioAS can you rebase your branch and add DCO checks? |
6af3f0c to
de6583e
Compare
Signed-off-by: fresioAS <andreas.fredhoi@three60energy.com>
Signed-off-by: fresioAS <andreas.fredhoi@three60energy.com>
Signed-off-by: fresioAS <andreas.fredhoi@three60energy.com>
Signed-off-by: fresioAS <andreas.fredhoi@three60energy.com>
de6583e to
e604319
Compare
|
@fresioAS Thanks for the PR! One blocker before merge: after a non-default catalog op (e.g. planning.*), the decorator restores with set_current_catalog(None) and keeps the ODBC connection on planning. If the next op targets the default catalog (e.g. core.db.table), set_current_catalog("core") normalizes to None and no-ops, so the query can still run against planning. We can distinguish set_current_catalog(None) (lazy restore) from an explicit switch to the default catalog name, and add a test: planning.* → core.* should reconnect and reset _connected_catalog. Let me know if I'm missing anything! |
|
@StuffbyYuki Thanks for the reply! Sounds reasonable. I will take a look at this when I am back from vacation in appx 2 weeks time! |
Description
Reduces excessive catalog-switching churn in the Fabric engine adapter.
Root cause:
get_current_catalog()was inherited fromGetCurrentCatalogFromFunctionMixin, executingSELECT db_name()on every call — including the two calls made by theset_catalogdecorator (switch-in + restore) wrapping every catalog-scoped operation. For Fabric, each SQL statement runs in an independent session, so this also triggered a connectionclose()+ reopen on every single restore, even when restoring to the same catalog.Changes:
Override
get_current_catalog()to read thread-local state (_target_catalog) instead of querying the database. Eliminates allSELECT db_name()round-trips.Treat the default catalog as neutral (
None) via_normalize_catalog(). The configureddatabaseis the implicit connection default — there is no meaningful distinction between "connected todefault" and "no catalog set", so both map toNone. This prevents the decorator from seeing a mismatch and unnecessarily switching back to the default after every operation.Lazy connection management via
_connected_catalogtracking.set_current_catalog()now distinguishes between the logical catalog target (_target_catalog) and the physical catalog the open connection is using (_connected_catalog). The connection is only closed and reopened when the physical connection actually needs to change:_target_catalogis updated, but the open connection is kept alive for reuse on the next call to the same catalog.Fix
_drop_catalogto check both_connected_catalogandget_current_catalog()(with default-db fallback) before closing all connections, so dropping the default warehouse is still handled correctly.Test Plan
get_current_catalog, default catalog clearing, restore-to-neutral without connection close, same-catalog reuse (1 close for N consecutive ops), and cross-catalog switching (1 close per genuine switch).Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCO