You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2022/10/03 20:44:30 UTC
[superset] branch fix-engine-params-ref created (now 8cbb2062a9)
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a change to branch fix-engine-params-ref
in repository https://gitbox.apache.org/repos/asf/superset.git
at 8cbb2062a9 pull reference
This branch includes the following new commits:
new 8cbb2062a9 pull reference
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[superset] 01/01: pull reference
Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch fix-engine-params-ref
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 8cbb2062a9c699bca665ac10768f0bfcedba6ba3
Author: hughhhh <hu...@gmail.com>
AuthorDate: Mon Oct 3 16:44:05 2022 -0400
pull reference
---
superset/db_engine_specs/gsheets.py | 18 ++++++++++++++++--
superset/models/core.py | 2 +-
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/superset/db_engine_specs/gsheets.py b/superset/db_engine_specs/gsheets.py
index 78b42d2b3a..3011d36903 100644
--- a/superset/db_engine_specs/gsheets.py
+++ b/superset/db_engine_specs/gsheets.py
@@ -31,6 +31,7 @@ from typing_extensions import TypedDict
from superset import security_manager
from superset.constants import PASSWORD_MASK
+from superset.databases.commands.exceptions import DatabaseExtraJSONValidationError
from superset.databases.schemas import encrypted_field_properties, EncryptedString
from superset.db_engine_specs.sqlite import SqliteEngineSpec
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
@@ -209,13 +210,26 @@ class GSheetsEngineSpec(SqliteEngineSpec):
spec.components.schema(cls.__name__, schema=cls.parameters_schema)
return spec.to_dict()["components"]["schemas"][cls.__name__]
+ @classmethod
+ def get_engine_parameters(cls, properties: Dict[str, Any]) -> Dict[str, Any]:
+ try:
+ if properties.get("extra"):
+ return json.loads(properties["extra"]).get("engine_params", {})
+ return {}
+ except TypeError as ex:
+ raise DatabaseExtraJSONValidationError(
+ "Unable to parse extra_json data"
+ ) from ex
+
@classmethod
def validate_parameters(
cls,
- properties: GSheetsPropertiesType,
+ properties: Dict[str, Any],
) -> List[SupersetError]:
errors: List[SupersetError] = []
- parameters = properties.get("parameters", {})
+
+ # {'id': 7, 'configuration_method': <ConfigurationMethod.DYNAMIC_FORM: 'dynamic_form'>, 'extra': '{"engine_params":{"catalog":{"query_error_logs":"https://docs.google.com/spreadsheets/d/1XGpBx5-SPwM9mcdqMBTQcQNt-3Aa5-TEusUp5OvwMWs"}},"metadata_params":{},"schemas_allowed_for_file_upload":[]}', 'server_cert': None, 'engine': 'gsheets', 'database_name': 'Google Sheets', 'impersonate_user': True, 'masked_encrypted_extra': '{}', 'driver': 'apsw'}
+ parameters = cls.get_engine_parameters(properties)
encrypted_credentials = parameters.get("service_account_info") or "{}"
# On create the encrypted credentials are a string,
diff --git a/superset/models/core.py b/superset/models/core.py
index b0f8bbb772..008230ef48 100755
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -261,7 +261,7 @@ class Database(
# When returning the parameters we should use the masked SQLAlchemy URI and the
# masked ``encrypted_extra`` to prevent exposing sensitive credentials.
masked_uri = make_url_safe(self.sqlalchemy_uri)
- masked_encrypted_extra = self.mask_encrypted_extra(self.encrypted_extra)
+ masked_encrypted_extra = self.masked_encrypted_extra
encrypted_config = {}
if masked_encrypted_extra is not None:
try: