Skip to content

Commit

Permalink
fix: always create parameter json field (#19899)
Browse files Browse the repository at this point in the history
* fix: always create parameter json field

* ensure validation for empty catalog

* check engine instead of name

* put validation in be

* fix test

* fix test

* remove test
  • Loading branch information
pkdotson authored May 25, 2022
1 parent 73443ce commit 0501ad2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions superset/db_engine_specs/gsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ def validate_parameters(

if not table_catalog:
# Allowing users to submit empty catalogs
errors.append(
SupersetError(
message="Sheet name is required",
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"catalog": {"idx": 0, "name": True}},
),
)
return errors

# We need a subject in case domain wide delegation is set, otherwise the
Expand Down
9 changes: 8 additions & 1 deletion tests/unit_tests/db_engine_specs/test_gsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ def test_validate_parameters_simple(
"catalog": {},
}
errors = GSheetsEngineSpec.validate_parameters(parameters)
assert errors == []
assert errors == [
SupersetError(
message="Sheet name is required",
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"catalog": {"idx": 0, "name": True}},
),
]


def test_validate_parameters_catalog(
Expand Down

0 comments on commit 0501ad2

Please sign in to comment.