FrancescoCastaldi commented on code in PR #43695:
URL: https://github.com/apache/superset/pull/43695#discussion_r4318117929
##########
superset/db_engine_specs/databricks.py:
##########
@@ -1011,6 +1019,68 @@ def build_sqlalchemy_uri( # type: ignore
query=query,
).render_as_string(hide_password=False)
+ @classmethod
+ def adjust_engine_params(
+ cls,
+ uri: URL,
+ connect_args: dict[str, Any],
+ catalog: str | None = None,
+ schema: str | None = None,
+ ) -> tuple[URL, dict[str, Any]]:
+ adjusted_connect_args = connect_args.copy()
+
+ original_catalog = (
+ adjusted_connect_args.get("catalog") or uri.query.get("catalog")
+ )
+ is_catalog_changing = (
Review Comment:
Addressed in commit `58d75109c1` (included in `d49752d642`).
We updated `DatabricksNativeEngineSpec.adjust_engine_params` so that
`is_catalog_changing` evaluates to true only when an original catalog is
explicitly configured and differs from the requested catalog (`catalog is not
None and original_catalog is not None and catalog != original_catalog`). When
no catalog is configured on the connection (`original_catalog is None`), the
URI-defined schema is preserved.
In `tests/unit_tests/db_engine_specs/test_databricks.py`, we added the
requested test cases pinning both paths:
1. A connection with no configured catalog (`/finance` URI with
`catalog="main"`, `schema=None`) keeps `schema="finance"`.
2. A connection with matching catalog in the URI (`/finance?catalog=main`
with `catalog="main"`, `schema=None`) preserves `schema="finance"`.
3. A connection switching away from a configured catalog
(`connect_args={"catalog": "main"}` with `catalog="other"`) cleanly resets to
`schema="default"`.
All unit tests pass cleanly.
--
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]