From 110720eb28909bdf7be11be22db331e779c1c35e Mon Sep 17 00:00:00 2001 From: Christian Pfarr Date: Fri, 5 Nov 2021 12:53:17 +0100 Subject: [PATCH 1/6] Added Drill ODBC Impersonation feature and necessary translations/docs --- docs/src/resources/openapi.json | 8 ++++---- .../CRUD/data/database/DatabaseModal/ExtraOptions.tsx | 2 +- superset/db_engine_specs/drill.py | 9 +++++++++ superset/translations/de/LC_MESSAGES/messages.json | 6 +++--- superset/translations/de/LC_MESSAGES/messages.po | 2 +- superset/translations/en/LC_MESSAGES/messages.json | 6 +++--- superset/translations/en/LC_MESSAGES/messages.po | 2 +- superset/translations/es/LC_MESSAGES/messages.json | 6 +++--- superset/translations/es/LC_MESSAGES/messages.po | 2 +- superset/translations/fr/LC_MESSAGES/messages.json | 6 +++--- superset/translations/fr/LC_MESSAGES/messages.po | 2 +- superset/translations/it/LC_MESSAGES/messages.json | 6 +++--- superset/translations/it/LC_MESSAGES/messages.po | 2 +- superset/translations/ja/LC_MESSAGES/messages.json | 6 +++--- superset/translations/ja/LC_MESSAGES/messages.po | 2 +- superset/translations/ko/LC_MESSAGES/messages.json | 6 +++--- superset/translations/ko/LC_MESSAGES/messages.po | 2 +- superset/translations/messages.pot | 2 +- superset/translations/pt/LC_MESSAGES/message.json | 6 +++--- superset/translations/pt/LC_MESSAGES/message.po | 2 +- superset/translations/pt/LC_MESSAGES/messages.json | 2 +- superset/translations/pt_BR/LC_MESSAGES/messages.json | 6 +++--- superset/translations/pt_BR/LC_MESSAGES/messages.po | 2 +- superset/translations/ru/LC_MESSAGES/messages.json | 6 +++--- superset/translations/ru/LC_MESSAGES/messages.po | 2 +- superset/translations/sl/LC_MESSAGES/messages.json | 6 +++--- superset/translations/sl/LC_MESSAGES/messages.po | 2 +- superset/translations/zh/LC_MESSAGES/messages.json | 8 ++++---- superset/translations/zh/LC_MESSAGES/messages.po | 4 ++-- 29 files changed, 66 insertions(+), 57 deletions(-) diff --git a/docs/src/resources/openapi.json b/docs/src/resources/openapi.json index 7181d3beca31c..cdd51639054a4 100644 --- a/docs/src/resources/openapi.json +++ b/docs/src/resources/openapi.json @@ -2722,7 +2722,7 @@ "type": "string" }, "impersonate_user": { - "description": "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", + "description": "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", "type": "boolean" }, "parameters": { @@ -2816,7 +2816,7 @@ "type": "string" }, "impersonate_user": { - "description": "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", + "description": "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", "type": "boolean" }, "parameters": { @@ -2866,7 +2866,7 @@ "type": "string" }, "impersonate_user": { - "description": "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", + "description": "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", "type": "boolean" }, "parameters": { @@ -2914,7 +2914,7 @@ "type": "string" }, "impersonate_user": { - "description": "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", + "description": "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", "type": "boolean" }, "parameters": { diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx index e1bd62ae777a1..3d28a4a434252 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx @@ -393,7 +393,7 @@ const ExtraOptions = ({ checked={!!db?.impersonate_user} onChange={onInputChange} labelText={t( - 'Impersonate logged in user (Presto, Trino, Hive, and GSheets)', + 'Impersonate logged in user (Presto, Trino, Drill, Hive, and GSheets)', )} /> Optional[str]: def adjust_database_uri(cls, uri: URL, selected_schema: Optional[str]) -> None: if selected_schema: uri.database = parse.quote(selected_schema, safe="") + + @classmethod + def modify_url_for_impersonation(cls, url: URL, impersonate_user: bool, username: Optional[str]) -> None: + if impersonate_user and username is not None: + if url.drivername == "drill+odbc": + url.query["DelegationUID"] = username + else: + url.username = username + diff --git a/superset/translations/de/LC_MESSAGES/messages.json b/superset/translations/de/LC_MESSAGES/messages.json index 092fcdb2d2117..c528f290c85d8 100644 --- a/superset/translations/de/LC_MESSAGES/messages.json +++ b/superset/translations/de/LC_MESSAGES/messages.json @@ -853,7 +853,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2001,8 +2001,8 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [""], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [""], + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow data upload": [""], diff --git a/superset/translations/de/LC_MESSAGES/messages.po b/superset/translations/de/LC_MESSAGES/messages.po index 368876e5af940..0c93c613bcb09 100644 --- a/superset/translations/de/LC_MESSAGES/messages.po +++ b/superset/translations/de/LC_MESSAGES/messages.po @@ -7282,7 +7282,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 diff --git a/superset/translations/en/LC_MESSAGES/messages.json b/superset/translations/en/LC_MESSAGES/messages.json index ec99be74a07cb..7e74c204afb45 100644 --- a/superset/translations/en/LC_MESSAGES/messages.json +++ b/superset/translations/en/LC_MESSAGES/messages.json @@ -793,7 +793,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -1907,8 +1907,8 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [""], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [""], + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow data upload": [""], diff --git a/superset/translations/en/LC_MESSAGES/messages.po b/superset/translations/en/LC_MESSAGES/messages.po index d3014fefe46f9..9298bf3d325d7 100644 --- a/superset/translations/en/LC_MESSAGES/messages.po +++ b/superset/translations/en/LC_MESSAGES/messages.po @@ -7281,7 +7281,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 diff --git a/superset/translations/es/LC_MESSAGES/messages.json b/superset/translations/es/LC_MESSAGES/messages.json index 070da628b3d0d..ed5cf69484104 100644 --- a/superset/translations/es/LC_MESSAGES/messages.json +++ b/superset/translations/es/LC_MESSAGES/messages.json @@ -936,7 +936,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "Cuando se permite la opción CREATE TABLE AS en el laboratorio SQL, esta opción hace que la tabla se cree en este esquema" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2166,8 +2166,8 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [""], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [""], + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow data upload": [""], diff --git a/superset/translations/es/LC_MESSAGES/messages.po b/superset/translations/es/LC_MESSAGES/messages.po index 37a08de605fbf..e7338302a91a0 100644 --- a/superset/translations/es/LC_MESSAGES/messages.po +++ b/superset/translations/es/LC_MESSAGES/messages.po @@ -7369,7 +7369,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 diff --git a/superset/translations/fr/LC_MESSAGES/messages.json b/superset/translations/fr/LC_MESSAGES/messages.json index 44a47dc0d7e0c..0af3d0e38b960 100644 --- a/superset/translations/fr/LC_MESSAGES/messages.json +++ b/superset/translations/fr/LC_MESSAGES/messages.json @@ -994,7 +994,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "Quand l'option autoriser CREATE TABLE AS dans SQL Lab est cochée, force la table a être créée dans le schéma" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Si Presto, toutes les requêtes dans SQL Lab sont en cours d'exécution sous le compte de l'utilisateur actuellement connecté qui doit avoir les premissions requises.
Si Hive et hive.server2.enable.doAs sont activés, les requêtes seront exécutées sous le compte du service, mais impersonnifiant l'utilisateur actuellement connecté via la propriété hive.server2.proxy.user." ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2288,10 +2288,10 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [ "Impersonnaliser la connexion de l'utilisateur" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Si Presto, toutes les requêtes dans SQL Lab sont en cours d'exécution sous le compte de l'utilisateur actuellement connecté qui doit avoir les premissions requises.
Si Hive et hive.server2.enable.doAs sont activés, les requêtes seront exécutées sous le compte du service, mais impersonnifiant l'utilisateur actuellement connecté via la propriété hive.server2.proxy.user." ], "Allow data upload": [""], diff --git a/superset/translations/fr/LC_MESSAGES/messages.po b/superset/translations/fr/LC_MESSAGES/messages.po index ca57acdbef01d..4416d9085ac68 100644 --- a/superset/translations/fr/LC_MESSAGES/messages.po +++ b/superset/translations/fr/LC_MESSAGES/messages.po @@ -7456,7 +7456,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "Impersonnaliser la connexion de l'utilisateur" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 diff --git a/superset/translations/it/LC_MESSAGES/messages.json b/superset/translations/it/LC_MESSAGES/messages.json index 9242089d9db63..17573079b2f68 100644 --- a/superset/translations/it/LC_MESSAGES/messages.json +++ b/superset/translations/it/LC_MESSAGES/messages.json @@ -860,7 +860,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "Se si abilita l'opzione CREATE TABLE AS in SQL Lab, verrà forzata la creazione della tabella con questo schema" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2038,8 +2038,8 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [""], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [""], + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow data upload": [""], diff --git a/superset/translations/it/LC_MESSAGES/messages.po b/superset/translations/it/LC_MESSAGES/messages.po index 7c2741b5c94ab..3480e465b1fea 100644 --- a/superset/translations/it/LC_MESSAGES/messages.po +++ b/superset/translations/it/LC_MESSAGES/messages.po @@ -7330,7 +7330,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 diff --git a/superset/translations/ja/LC_MESSAGES/messages.json b/superset/translations/ja/LC_MESSAGES/messages.json index 38a3e99270055..ac886ef463a86 100644 --- a/superset/translations/ja/LC_MESSAGES/messages.json +++ b/superset/translations/ja/LC_MESSAGES/messages.json @@ -1094,7 +1094,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2396,8 +2396,8 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [""], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [""], + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow data upload": [""], diff --git a/superset/translations/ja/LC_MESSAGES/messages.po b/superset/translations/ja/LC_MESSAGES/messages.po index 39d6e5e95e3cc..0924a7609a500 100644 --- a/superset/translations/ja/LC_MESSAGES/messages.po +++ b/superset/translations/ja/LC_MESSAGES/messages.po @@ -8008,7 +8008,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:570 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:573 diff --git a/superset/translations/ko/LC_MESSAGES/messages.json b/superset/translations/ko/LC_MESSAGES/messages.json index 2ff6203ddc110..04b4f191a0a48 100644 --- a/superset/translations/ko/LC_MESSAGES/messages.json +++ b/superset/translations/ko/LC_MESSAGES/messages.json @@ -901,7 +901,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2093,8 +2093,8 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [""], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [""], + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "" ], "Allow data upload": [""], diff --git a/superset/translations/ko/LC_MESSAGES/messages.po b/superset/translations/ko/LC_MESSAGES/messages.po index 3287f07927b8a..2fcd8de014601 100644 --- a/superset/translations/ko/LC_MESSAGES/messages.po +++ b/superset/translations/ko/LC_MESSAGES/messages.po @@ -7789,7 +7789,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:591 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:593 diff --git a/superset/translations/messages.pot b/superset/translations/messages.pot index 9d149a93aa5b4..a3236074ab15f 100644 --- a/superset/translations/messages.pot +++ b/superset/translations/messages.pot @@ -8008,7 +8008,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:570 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:573 diff --git a/superset/translations/pt/LC_MESSAGES/message.json b/superset/translations/pt/LC_MESSAGES/message.json index 272ae85934a64..491bf8a5e7aac 100644 --- a/superset/translations/pt/LC_MESSAGES/message.json +++ b/superset/translations/pt/LC_MESSAGES/message.json @@ -928,7 +928,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "Ao permitir a opção CREATE TABLE AS no SQL Lab, esta opção força a tabela a ser criada neste esquema" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Se Presto, todas as consultas no SQL Lab serão executadas como o utilizador atualmente conectado que deve ter permissão para as executar.
Se hive e hive.server2.enable.doAs estiver habilitado, serão executadas as queries como conta de serviço, mas deve personificar o utilizador atualmente conectado recorrendo à propriedade hive.server2.proxy.user." ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2184,10 +2184,10 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [ "Personificar o utilizador conectado" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Se Presto, todas as consultas no SQL Lab serão executadas como o utilizador atualmente conectado que deve ter permissão para as executar.
Se hive e hive.server2.enable.doAs estiver habilitado, serão executadas as queries como conta de serviço, mas deve personificar o utilizador atualmente conectado recorrendo à propriedade hive.server2.proxy.user." ], "Allow Data Upload": [""], diff --git a/superset/translations/pt/LC_MESSAGES/message.po b/superset/translations/pt/LC_MESSAGES/message.po index 8e56cac5eab91..7fba415fee040 100644 --- a/superset/translations/pt/LC_MESSAGES/message.po +++ b/superset/translations/pt/LC_MESSAGES/message.po @@ -7331,7 +7331,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "Personificar o utilizador conectado" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 diff --git a/superset/translations/pt/LC_MESSAGES/messages.json b/superset/translations/pt/LC_MESSAGES/messages.json index 9bb3d757611db..eb31dd3e488c5 100644 --- a/superset/translations/pt/LC_MESSAGES/messages.json +++ b/superset/translations/pt/LC_MESSAGES/messages.json @@ -1195,7 +1195,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "Ao permitir a opção CREATE TABLE AS no SQL Lab, esta opção força a tabela a ser criada neste esquema" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Se Presto, todas as consultas no SQL Lab serão executadas como o utilizador atualmente conectado que deve ter permissão para as executar.
Se hive e hive.server2.enable.doAs estiver habilitado, serão executadas as queries como conta de serviço, mas deve personificar o utilizador atualmente conectado recorrendo à propriedade hive.server2.proxy.user." ], "Expose in SQL Lab": ["Expor no SQL Lab"], diff --git a/superset/translations/pt_BR/LC_MESSAGES/messages.json b/superset/translations/pt_BR/LC_MESSAGES/messages.json index b1edce97e6978..5dd86d91c1559 100644 --- a/superset/translations/pt_BR/LC_MESSAGES/messages.json +++ b/superset/translations/pt_BR/LC_MESSAGES/messages.json @@ -1215,7 +1215,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "Ao permitir a opção CREATE TABLE AS no SQL Lab, esta opção força a tabela a ser criada neste esquema" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Se Presto, todas as consultas no SQL Lab serão executadas como o usuário atualmente conectado que deve ter permissão para executá-las.
Se hive e hive.server2.enable.doAs estiver habilitado, será executado as consultas como conta de serviço, mas personifique o usuário atualmente conectado usando a propriedade hive.server2.proxy.user." ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2641,10 +2641,10 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "Conteúdo CA_BUNDLE opcional para validar requisições HTTPS. Disponível apenas em certos bancos de dados." ], - "Impersonate Logged In User (Presto & Hive)": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [ "Personificar usuário logado (Presto e Hive)" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Se Presto, todas as consultas no SQL Lab serão executadas utilizando o usuário logado atual que deve ter permissão para executá-las. Se Hive e hive.server2.enable.doAs for habilitado, as consultas serão executadas como conta de serviço, mas personificarão o usuário logado atual via propriedade hive.server2.proxy.user." ], "Allow data upload": ["Permitir carga de dados"], diff --git a/superset/translations/pt_BR/LC_MESSAGES/messages.po b/superset/translations/pt_BR/LC_MESSAGES/messages.po index 6a6bc21247049..004a88260a36b 100644 --- a/superset/translations/pt_BR/LC_MESSAGES/messages.po +++ b/superset/translations/pt_BR/LC_MESSAGES/messages.po @@ -7759,7 +7759,7 @@ msgstr "" "apenas em certos bancos de dados." #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "Personificar usuário logado (Presto e Hive)" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 diff --git a/superset/translations/ru/LC_MESSAGES/messages.json b/superset/translations/ru/LC_MESSAGES/messages.json index 9e64f9dfe14a7..713ea6c2dac01 100644 --- a/superset/translations/ru/LC_MESSAGES/messages.json +++ b/superset/translations/ru/LC_MESSAGES/messages.json @@ -1131,7 +1131,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "При разрешении опции CREATE TABLE AS в редакторе SQL эта опция создаст таблицу в выбранной схеме" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Если вы используете Presto, все запросы в SQL-Редакторе будут выполняться от авторизованного пользователя, который должен иметь разрешение на их выполнение.
Если включен Hive, то запросы будут выполняться через техническую учетную запись, но ассоциировать зарегистрированного пользователя можно через свойство hive.server2.proxy.user." ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2517,10 +2517,10 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "" ], - "Impersonate Logged In User (Presto & Hive)": [ + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [ "Ассоциировать пользователя" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "Если вы используете Presto, все запросы в SQL-Редакторе будут выполняться от авторизованного пользователя, который должен иметь разрешение на их выполнение.
Если включен Hive, то запросы будут выполняться через техническую учетную запись, но ассоциировать зарегистрированного пользователя можно через свойство hive.server2.proxy.user." ], "Allow data upload": ["Разрешить загрузку данных"], diff --git a/superset/translations/ru/LC_MESSAGES/messages.po b/superset/translations/ru/LC_MESSAGES/messages.po index a49ca4ea19faa..8a3dd2f2ef11c 100644 --- a/superset/translations/ru/LC_MESSAGES/messages.po +++ b/superset/translations/ru/LC_MESSAGES/messages.po @@ -7600,7 +7600,7 @@ msgid "" msgstr "" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" msgstr "Ассоциировать пользователя" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 diff --git a/superset/translations/sl/LC_MESSAGES/messages.json b/superset/translations/sl/LC_MESSAGES/messages.json index 47f702710546d..9e5ff5b02dc3b 100644 --- a/superset/translations/sl/LC_MESSAGES/messages.json +++ b/superset/translations/sl/LC_MESSAGES/messages.json @@ -1429,7 +1429,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "Z dovolitvijo opcije CREATE TABLE AS v SQL laboratoriju se tabele ustvarjajo s to shemo" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "V primeru Presto se vse poizvedbe v SQL laboratoriju zaženejo pod trenutno prijavljenim uporabnikom, ki mora imeti pravice za poganjanje.
Če je omogočen Hive in hive.server2.enable.doAs, poizvedbe tečejo pod servisnim računom, vendar je trenutno prijavljen uporabnik predstavljen z lastnostjo hive.server2.proxy.user." ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -3054,10 +3054,10 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "Opcijska CA_BUNDLE vsebina, za potrjevanje HTTPS zahtev. Razpoložljivo le na določenih sistemih podatkovnih baz." ], - "Impersonate Logged In User (Presto, Hive, and GSheets)": [ + "Impersonate Logged In User (Presto, Trino, Drill, Hive, and GSheets)": [ "Predstavljanje kot prijavljeni uporabnik (Presto, Hive in GSheets)" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "V Presto se vse poizvedbe v SQL laboratoriju zaženejo pod trenutno prijavljenim uporabnikom, ki mora imeti pravice za poganjanje. Če je omogočen Hive in hive.server2.enable.doAs, poizvedbe tečejo pod servisnim računom, vendar je trenutno prijavljen uporabnik predstavljen z lastnostjo hive.server2.proxy.user." ], "Allow data upload": ["Dovoli nalaganje podatkov"], diff --git a/superset/translations/sl/LC_MESSAGES/messages.po b/superset/translations/sl/LC_MESSAGES/messages.po index 80b3f3f0534d3..e56dbf6265863 100644 --- a/superset/translations/sl/LC_MESSAGES/messages.po +++ b/superset/translations/sl/LC_MESSAGES/messages.po @@ -9234,7 +9234,7 @@ msgstr "" "določenih sistemih podatkovnih baz." #: superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx:294 -msgid "Impersonate Logged In User (Presto, Hive, and GSheets)" +msgid "Impersonate Logged In User (Presto, Trino, Drill, Hive, and GSheets)" msgstr "Predstavljanje kot prijavljeni uporabnik (Presto, Hive in GSheets)" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx:299 diff --git a/superset/translations/zh/LC_MESSAGES/messages.json b/superset/translations/zh/LC_MESSAGES/messages.json index 7245e11d5cc79..035be3ff92762 100644 --- a/superset/translations/zh/LC_MESSAGES/messages.json +++ b/superset/translations/zh/LC_MESSAGES/messages.json @@ -994,7 +994,7 @@ "When allowing CREATE TABLE AS option in SQL Lab, this option forces the table to be created in this schema": [ "当在 SQL 编辑器中允许 CREATE TABLE AS 选项时,此选项可以此模式中强制创建表" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "如果使用Presto,SQL 工具箱中的所有查询都将被当前登录的用户执行,并且这些用户必须拥有运行它们的权限。
如果启用 Hive 和hive.server2.enable.doAs,将作为服务帐户运行查询,但会根据hive.server2.proxy.user的属性伪装当前登录用户。" ], "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.": [ @@ -2280,10 +2280,10 @@ "Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.": [ "用于验证HTTPS请求的可选 CA_BUNDLE 内容。仅在某些数据库引擎上可用。" ], - "Impersonate Logged In User (Presto & Hive)": [ - "模拟登录用户 (Presto & Hive)" + "Impersonate Logged In User (Presto, Trino, Drill & Hive)": [ + "模拟登录用户 (Presto, Trino, Drill & Hive)" ], - "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ + "If Presto, Trino or Drill all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them. If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.": [ "如果使用Presto,SQL 工具箱中的所有查询都将被当前登录的用户执行,并且这些用户必须拥有运行它们的权限。如果启用 Hive 和 hive.server2.enable.doAs,将作为服务帐户运行查询,但会根据 hive.server2.proxy.user 的属性伪装当前登录用户。" ], "Allow data upload": ["允许数据上传"], diff --git a/superset/translations/zh/LC_MESSAGES/messages.po b/superset/translations/zh/LC_MESSAGES/messages.po index 5108e35438fa9..9b490609f7249 100644 --- a/superset/translations/zh/LC_MESSAGES/messages.po +++ b/superset/translations/zh/LC_MESSAGES/messages.po @@ -7417,8 +7417,8 @@ msgid "" msgstr "用于验证HTTPS请求的可选 CA_BUNDLE 内容。仅在某些数据库引擎上可用。" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:608 -msgid "Impersonate Logged In User (Presto & Hive)" -msgstr "模拟登录用户 (Presto & Hive)" +msgid "Impersonate Logged In User (Presto, Trino, Drill & Hive)" +msgstr "模拟登录用户 (Presto, Trino, Drill & Hive)" #: superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx:610 msgid "" From 0d11745cda944a32a317f7403a12c75223c4aa13 Mon Sep 17 00:00:00 2001 From: Christian Pfarr Date: Sun, 7 Nov 2021 21:11:59 +0100 Subject: [PATCH 2/6] Code Cleanup --- superset/db_engine_specs/drill.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/superset/db_engine_specs/drill.py b/superset/db_engine_specs/drill.py index 21c57b3213eec..24ddaf5e161ae 100644 --- a/superset/db_engine_specs/drill.py +++ b/superset/db_engine_specs/drill.py @@ -70,10 +70,17 @@ def adjust_database_uri(cls, uri: URL, selected_schema: Optional[str]) -> None: uri.database = parse.quote(selected_schema, safe="") @classmethod - def modify_url_for_impersonation(cls, url: URL, impersonate_user: bool, username: Optional[str]) -> None: + def modify_url_for_impersonation( + cls, url: URL, impersonate_user: bool, username: Optional[str] + ) -> None: + """ + Modify the SQL Alchemy URL object with the user to impersonate if applicable. + :param url: SQLAlchemy URL object + :param impersonate_user: Flag indicating if impersonation is enabled + :param username: Effective username + """ if impersonate_user and username is not None: if url.drivername == "drill+odbc": url.query["DelegationUID"] = username - else: + else: url.username = username - From c12cc4457cf83bea3c3eb03aa8131f2a132eecec Mon Sep 17 00:00:00 2001 From: Christian Pfarr Date: Mon, 8 Nov 2021 09:06:34 +0100 Subject: [PATCH 3/6] add jdbc impersonation_target parameter --- superset/db_engine_specs/drill.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/superset/db_engine_specs/drill.py b/superset/db_engine_specs/drill.py index 24ddaf5e161ae..5b61282ac49ff 100644 --- a/superset/db_engine_specs/drill.py +++ b/superset/db_engine_specs/drill.py @@ -82,5 +82,7 @@ def modify_url_for_impersonation( if impersonate_user and username is not None: if url.drivername == "drill+odbc": url.query["DelegationUID"] = username + elif url.drivername == "drill+jdbc": + url.query["impersonation_target"] = username else: url.username = username From 5e49f1fa4db9fa5a76da6fb06818bbacda516463 Mon Sep 17 00:00:00 2001 From: Christian Pfarr Date: Tue, 9 Nov 2021 09:24:15 +0100 Subject: [PATCH 4/6] add unittests for DrillEngineSpec.modify_url_for_impersonation method --- .../unit_tests/db_engine_specs/test_drill.py | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/unit_tests/db_engine_specs/test_drill.py diff --git a/tests/unit_tests/db_engine_specs/test_drill.py b/tests/unit_tests/db_engine_specs/test_drill.py new file mode 100644 index 0000000000000..543fa7598561c --- /dev/null +++ b/tests/unit_tests/db_engine_specs/test_drill.py @@ -0,0 +1,61 @@ +# 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. +# pylint: disable=unused-argument, import-outside-toplevel, protected-access + +from flask.ctx import AppContext + + +def test_odbc_impersonation(app_context: AppContext) -> None: + """ + Test ``modify_url_for_impersonation`` method when driver == odbc. + + The method adds the parameter ``DelegationUID`` to the query string. + """ + from superset.db_engine_specs.drill import DrillEngineSpec + from sqlalchemy.engine.url import URL + url = URL("drill+odbc") + username = "DoAsUser" + DrillEngineSpec.modify_url_for_impersonation(url, True, username) + assert (url.query["DelegationUID"] == username) + + +def test_jdbc_impersonation(app_context: AppContext) -> None: + """ + Test ``modify_url_for_impersonation`` method when driver == jdbc. + + The method adds the parameter ``impersonation_target`` to the query string. + """ + from superset.db_engine_specs.drill import DrillEngineSpec + from sqlalchemy.engine.url import URL + url = URL("drill+jdbc") + username = "DoAsUser" + DrillEngineSpec.modify_url_for_impersonation(url, True, username) + assert (url.query["impersonation_target"] == username) + + +def test_sadrill_impersonation(app_context: AppContext) -> None: + """ + Test ``modify_url_for_impersonation`` method when driver == sadrill. + + The method changes the username of URL Object. + """ + from superset.db_engine_specs.drill import DrillEngineSpec + from sqlalchemy.engine.url import URL + url = URL("drill+sadrill") + username = "DoAsUser" + DrillEngineSpec.modify_url_for_impersonation(url, True, username) + assert (url.username == username) From 668e1cc42079174ecb1cd6dc94149562c0673407 Mon Sep 17 00:00:00 2001 From: Christian Pfarr Date: Tue, 9 Nov 2021 11:52:44 +0100 Subject: [PATCH 5/6] reformat test_drill.py with black formatter --- .../unit_tests/db_engine_specs/test_drill.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/unit_tests/db_engine_specs/test_drill.py b/tests/unit_tests/db_engine_specs/test_drill.py index 543fa7598561c..49a666914e2ce 100644 --- a/tests/unit_tests/db_engine_specs/test_drill.py +++ b/tests/unit_tests/db_engine_specs/test_drill.py @@ -21,41 +21,44 @@ def test_odbc_impersonation(app_context: AppContext) -> None: """ - Test ``modify_url_for_impersonation`` method when driver == odbc. + Test ``modify_url_for_impersonation`` method when driver == odbc. - The method adds the parameter ``DelegationUID`` to the query string. + The method adds the parameter ``DelegationUID`` to the query string. """ from superset.db_engine_specs.drill import DrillEngineSpec from sqlalchemy.engine.url import URL + url = URL("drill+odbc") username = "DoAsUser" DrillEngineSpec.modify_url_for_impersonation(url, True, username) - assert (url.query["DelegationUID"] == username) + assert url.query["DelegationUID"] == username def test_jdbc_impersonation(app_context: AppContext) -> None: """ - Test ``modify_url_for_impersonation`` method when driver == jdbc. + Test ``modify_url_for_impersonation`` method when driver == jdbc. - The method adds the parameter ``impersonation_target`` to the query string. + The method adds the parameter ``impersonation_target`` to the query string. """ from superset.db_engine_specs.drill import DrillEngineSpec from sqlalchemy.engine.url import URL + url = URL("drill+jdbc") username = "DoAsUser" DrillEngineSpec.modify_url_for_impersonation(url, True, username) - assert (url.query["impersonation_target"] == username) + assert url.query["impersonation_target"] == username def test_sadrill_impersonation(app_context: AppContext) -> None: """ - Test ``modify_url_for_impersonation`` method when driver == sadrill. + Test ``modify_url_for_impersonation`` method when driver == sadrill. - The method changes the username of URL Object. + The method changes the username of URL Object. """ from superset.db_engine_specs.drill import DrillEngineSpec from sqlalchemy.engine.url import URL + url = URL("drill+sadrill") username = "DoAsUser" DrillEngineSpec.modify_url_for_impersonation(url, True, username) - assert (url.username == username) + assert url.username == username From da4f9a1ce65e70a3c1774c1831389dd17facfbd2 Mon Sep 17 00:00:00 2001 From: Christian Pfarr Date: Tue, 9 Nov 2021 12:07:57 +0100 Subject: [PATCH 6/6] run pre-commit locally --- tests/unit_tests/db_engine_specs/test_drill.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/unit_tests/db_engine_specs/test_drill.py b/tests/unit_tests/db_engine_specs/test_drill.py index 49a666914e2ce..08f7972d80b78 100644 --- a/tests/unit_tests/db_engine_specs/test_drill.py +++ b/tests/unit_tests/db_engine_specs/test_drill.py @@ -25,9 +25,10 @@ def test_odbc_impersonation(app_context: AppContext) -> None: The method adds the parameter ``DelegationUID`` to the query string. """ - from superset.db_engine_specs.drill import DrillEngineSpec from sqlalchemy.engine.url import URL + from superset.db_engine_specs.drill import DrillEngineSpec + url = URL("drill+odbc") username = "DoAsUser" DrillEngineSpec.modify_url_for_impersonation(url, True, username) @@ -40,9 +41,10 @@ def test_jdbc_impersonation(app_context: AppContext) -> None: The method adds the parameter ``impersonation_target`` to the query string. """ - from superset.db_engine_specs.drill import DrillEngineSpec from sqlalchemy.engine.url import URL + from superset.db_engine_specs.drill import DrillEngineSpec + url = URL("drill+jdbc") username = "DoAsUser" DrillEngineSpec.modify_url_for_impersonation(url, True, username) @@ -55,9 +57,10 @@ def test_sadrill_impersonation(app_context: AppContext) -> None: The method changes the username of URL Object. """ - from superset.db_engine_specs.drill import DrillEngineSpec from sqlalchemy.engine.url import URL + from superset.db_engine_specs.drill import DrillEngineSpec + url = URL("drill+sadrill") username = "DoAsUser" DrillEngineSpec.modify_url_for_impersonation(url, True, username)