mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
fix(drill): specify an SA URL parm of impersonation_target for drill+sadrill (#19252)
* Update drill+sadrill to specify an SA URL parm of "impersonation_target". Sqlalchemy-drill is being updated to support impersonation with the drill+sadrill driver, where previously it did not. The way that callers should specify impersonation matches that for the drill+jdbc driver in that a SA URL parameter of impersonation_target should be set to the username of the user to be impersonated, while the stadard SA username and password should be those of the proxy user. * Remove lint. * Address review comments. * Use idiomatic pytest to test for a raised exception. * Fix import statement order in drill.py.
This commit is contained in:
@@ -21,6 +21,7 @@ from urllib import parse
|
||||
from sqlalchemy.engine.url import URL
|
||||
|
||||
from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.db_engine_specs.exceptions import SupersetDBAPIProgrammingError
|
||||
from superset.utils import core as utils
|
||||
|
||||
|
||||
@@ -84,7 +85,9 @@ class DrillEngineSpec(BaseEngineSpec):
|
||||
if impersonate_user and username is not None:
|
||||
if url.drivername == "drill+odbc":
|
||||
url.query["DelegationUID"] = username
|
||||
elif url.drivername == "drill+jdbc":
|
||||
elif url.drivername in ["drill+sadrill", "drill+jdbc"]:
|
||||
url.query["impersonation_target"] = username
|
||||
else:
|
||||
url.username = username
|
||||
raise SupersetDBAPIProgrammingError(
|
||||
f"impersonation is not supported for {url.drivername}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user