Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/data/databases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3707,7 +3707,7 @@
"engine": "databricks",
"engine_name": "Databricks",
"engine_aliases": [],
"default_driver": "databricks-sql-python",
"default_driver": "databricks",
"supports_file_upload": true,
"supports_dynamic_schema": true,
"supports_catalog": true,
Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ def validate_parameters( # type: ignore
class DatabricksPythonConnectorEngineSpec(DatabricksDynamicBaseEngineSpec):
engine = "databricks"
engine_name = "Databricks"
default_driver = "databricks-sql-python"
drivers = {"databricks-sql-python": "Databricks SQL Python"}
default_driver = "databricks"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: If only a legacy Databricks driver is installed, the API omits this spec’s parameters but still selects this default; URI mode then uses the unavailable Python dialect and connections fail.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Api mismatch

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/db_engine_specs/databricks.py
**Line:** 745:745
**Comment:**
	*Api Mismatch: If only a legacy Databricks driver is installed, the API omits this spec’s parameters but still selects this default; URI mode then uses the unavailable Python dialect and connections fail.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

drivers = {"databricks": "Databricks SQL Python"}

parameters_schema = DatabricksPythonConnectorSchema()

Expand Down
27 changes: 27 additions & 0 deletions tests/unit_tests/databases/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3044,3 +3044,30 @@ def test_related_objects_limits_dataset_details(
assert payload["count"] == MAX_RELATED_DATASETS + 2
assert len(payload["result"]) == MAX_RELATED_DATASETS
assert can_access.call_count == MAX_RELATED_DATASETS


def test_available_databricks_includes_dynamic_form(
client: FlaskClient,
full_api_access: None,
mocker: MockerFixture,
) -> None:
"""An installed official Databricks driver exposes the connection form."""
from superset.db_engine_specs.databricks import DatabricksPythonConnectorEngineSpec

mocker.patch(
"superset.databases.api.get_available_engine_specs",
return_value={DatabricksPythonConnectorEngineSpec: {"databricks"}},
)

response = client.get("/api/v1/database/available/")

assert response.status_code == 200
assert response.json is not None
entry = response.json["databases"][0]
assert entry["engine"] == "databricks"
assert entry["available_drivers"] == ["databricks"]
assert entry["default_driver"] == "databricks"
assert entry["parameters"]
assert {"host", "http_path_field", "access_token"} <= set(
entry["parameters"]["properties"]
)
7 changes: 6 additions & 1 deletion tests/unit_tests/db_engine_specs/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,11 +1403,16 @@ def test_get_engine_spec_unrecognized_driver_prefers_python_connector() -> None:
is DatabricksPythonConnectorEngineSpec
)

assert (
get_engine_spec("databricks", "databricks-sql-python")
is DatabricksPythonConnectorEngineSpec
)

# Exact driver matches must still resolve to their specific spec; the
# relocation must not disturb exact-match resolution.
assert get_engine_spec("databricks", "pyhive") is DatabricksHiveEngineSpec
assert (
get_engine_spec("databricks", "databricks-sql-python")
get_engine_spec("databricks", "databricks")
is DatabricksPythonConnectorEngineSpec
)

Expand Down
Loading