You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2023/01/13 22:50:26 UTC
[superset] branch master updated: fix: remove whitespace from http_path for databricks (#22671)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new cd1f6d469b fix: remove whitespace from http_path for databricks (#22671)
cd1f6d469b is described below
commit cd1f6d469b34c7c211c7b990ccfbde8909ecbea4
Author: Elizabeth Thompson <es...@gmail.com>
AuthorDate: Fri Jan 13 14:50:18 2023 -0800
fix: remove whitespace from http_path for databricks (#22671)
---
superset/db_engine_specs/databricks.py | 5 +++++
.../unit_tests/db_engine_specs/test_databricks.py | 22 ++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/superset/db_engine_specs/databricks.py b/superset/db_engine_specs/databricks.py
index 131679359c..98fc44e77f 100644
--- a/superset/db_engine_specs/databricks.py
+++ b/superset/db_engine_specs/databricks.py
@@ -162,6 +162,7 @@ class DatabricksNativeEngineSpec(DatabricksODBCEngineSpec, BasicParametersMixin)
def get_extra_params(database: "Database") -> Dict[str, Any]:
"""
Add a user agent to be used in the requests.
+ Trim whitespace from connect_args to avoid databricks driver errors
"""
extra: Dict[str, Any] = BaseEngineSpec.get_extra_params(database)
engine_params: Dict[str, Any] = extra.setdefault("engine_params", {})
@@ -170,6 +171,10 @@ class DatabricksNativeEngineSpec(DatabricksODBCEngineSpec, BasicParametersMixin)
connect_args.setdefault("http_headers", [("User-Agent", USER_AGENT)])
connect_args.setdefault("_user_agent_entry", USER_AGENT)
+ # trim whitespace from http_path to avoid databricks errors on connecting
+ if http_path := connect_args.get("http_path"):
+ connect_args["http_path"] = http_path.strip()
+
return extra
@classmethod
diff --git a/tests/unit_tests/db_engine_specs/test_databricks.py b/tests/unit_tests/db_engine_specs/test_databricks.py
index 50c7fd47a3..1962f4af36 100644
--- a/tests/unit_tests/db_engine_specs/test_databricks.py
+++ b/tests/unit_tests/db_engine_specs/test_databricks.py
@@ -175,3 +175,25 @@ def test_get_extra_params(mocker: MockerFixture) -> None:
}
}
}
+
+ # it should also remove whitespace from http_path
+ database.extra = json.dumps(
+ {
+ "engine_params": {
+ "connect_args": {
+ "http_headers": [("User-Agent", "Custom user agent")],
+ "_user_agent_entry": "Custom user agent",
+ "http_path": "/some_path_here_with_whitespace ",
+ }
+ }
+ }
+ )
+ assert DatabricksNativeEngineSpec.get_extra_params(database) == {
+ "engine_params": {
+ "connect_args": {
+ "http_headers": [["User-Agent", "Custom user agent"]],
+ "_user_agent_entry": "Custom user agent",
+ "http_path": "/some_path_here_with_whitespace",
+ }
+ }
+ }