Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix deprecation warnings for SQLALchemy URL #23770

Merged
merged 1 commit into from
May 11, 2023
Merged
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 superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ def build_sqlalchemy_uri( # pylint: disable=unused-argument
query.update(cls.encryption_parameters)

return str(
URL(
URL.create(
f"{cls.engine}+{cls.default_driver}".rstrip("+"), # type: ignore
username=parameters.get("username"),
password=parameters.get("password"),
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def build_sqlalchemy_uri(
if not url_params.get("database"):
url_params["database"] = "__default__"
url_params.pop("encryption", None)
return str(URL(f"{cls.engine}+{cls.default_driver}", **url_params))
return str(URL.create(f"{cls.engine}+{cls.default_driver}", **url_params))

@classmethod
def get_parameters_from_uri(
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def build_sqlalchemy_uri( # type: ignore
query.update(cls.encryption_parameters)

return str(
URL(
URL.create(
f"{cls.engine}+{cls.default_driver}".rstrip("+"),
username="token",
password=parameters.get("access_token"),
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def build_sqlalchemy_uri(
] = None,
) -> str:
return str(
URL(
URL.create(
"snowflake",
username=parameters.get("username"),
password=parameters.get("password"),
Expand Down
8 changes: 4 additions & 4 deletions tests/unit_tests/db_engine_specs/test_drill.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_odbc_impersonation() -> None:

from superset.db_engine_specs.drill import DrillEngineSpec

url = URL("drill+odbc")
url = URL.create("drill+odbc")
username = "DoAsUser"
url = DrillEngineSpec.get_url_for_impersonation(url, True, username)
assert url.query["DelegationUID"] == username
Expand All @@ -52,7 +52,7 @@ def test_jdbc_impersonation() -> None:

from superset.db_engine_specs.drill import DrillEngineSpec

url = URL("drill+jdbc")
url = URL.create("drill+jdbc")
username = "DoAsUser"
url = DrillEngineSpec.get_url_for_impersonation(url, True, username)
assert url.query["impersonation_target"] == username
Expand All @@ -68,7 +68,7 @@ def test_sadrill_impersonation() -> None:

from superset.db_engine_specs.drill import DrillEngineSpec

url = URL("drill+sadrill")
url = URL.create("drill+sadrill")
username = "DoAsUser"
url = DrillEngineSpec.get_url_for_impersonation(url, True, username)
assert url.query["impersonation_target"] == username
Expand All @@ -86,7 +86,7 @@ def test_invalid_impersonation() -> None:
from superset.db_engine_specs.drill import DrillEngineSpec
from superset.db_engine_specs.exceptions import SupersetDBAPIProgrammingError

url = URL("drill+foobar")
url = URL.create("drill+foobar")
username = "DoAsUser"

with pytest.raises(SupersetDBAPIProgrammingError):
Expand Down