Skip to content

Commit

Permalink
reference catalog for gsheets validation
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Oct 5, 2022
1 parent 51c54b3 commit b76003d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ class Meta: # pylint: disable=too-few-public-methods
values=fields.Raw(allow_none=True),
description="DB-specific parameters for configuration",
)
catalog = fields.List(
fields.Dict(
keys=fields.String(),
values=fields.Raw(allow_none=True),
description="Gsheets specific column for managing label to sheet urls",
)
)
database_name = fields.String(
description=database_name_description,
allow_none=True,
Expand Down
10 changes: 8 additions & 2 deletions superset/db_engine_specs/gsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,22 @@ def validate_parameters(
properties: GSheetsPropertiesType,
) -> List[SupersetError]:
errors: List[SupersetError] = []

# backwards compatible just incase people are send data
# via parameters for validation
parameters = properties.get("parameters", {})
if parameters:
table_catalog = parameters.get("catalog", {})
else:
table_catalog = properties.get("catalog", {})

encrypted_credentials = parameters.get("service_account_info") or "{}"

# On create the encrypted credentials are a string,
# at all other times they are a dict
if isinstance(encrypted_credentials, str):
encrypted_credentials = json.loads(encrypted_credentials)

table_catalog = parameters.get("catalog", {})

if not table_catalog:
# Allowing users to submit empty catalogs
errors.append(
Expand Down

0 comments on commit b76003d

Please sign in to comment.