sadpandajoe commented on code in PR #43695:
URL: https://github.com/apache/superset/pull/43695#discussion_r4273997146
##########
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 = (
Review Comment:
The repo's `ruff-format` pre-commit hook rewrites these new expressions (the
parenthesized `original_catalog`/`is_catalog_changing` assignments here, and
the matching ones around `test_databricks.py:172`), so the formatting check
will fail until the formatted output is committed. Could you run `ruff format`
on both files?
##########
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:
This treats a catalog that was never configured on the connection as a
catalog change, so the saved schema is discarded. With a URI like
`.../finance?http_path=...` (no `catalog`), the server default catalog resolves
through `get_default_catalog()`, and dataset creation then calls this with
`catalog="main"`, `schema=None`. `original_catalog` is `None`,
`is_catalog_changing` is true, and the schema becomes `"default"`, so
reflection looks for `main.default.orders` instead of `main.finance.orders`.
Could the reset to `"default"` apply only when the caller names a catalog
different from an explicitly configured one, and keep the URI schema otherwise?
The new same-catalog test at `test_databricks.py:184` also can't catch this
because the saved schema and the reset value are both `"default"`; a case using
`/finance?catalog=main` with `catalog="main"` and a no-catalog `/finance` URI
with `catalog="main"` would pin both paths.
##########
tests/unit_tests/db_engine_specs/test_lint_metadata.py:
##########
@@ -0,0 +1,244 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from pathlib import Path
+from textwrap import dedent
+
+import pytest
+
+import io
Review Comment:
`import io` sits after the third-party `pytest` import, so Ruff's
import-sorting rule (`I001`) flags this file. Could it move up into the stdlib
group with `pathlib` and `textwrap`?
--
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]