Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add Validation to Snowflake Form [WIP] #17022

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superset/databases/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from superset.extensions import event_logger
from superset.models.core import Database

BYPASS_VALIDATION_ENGINES = {"bigquery", "snowflake"}
BYPASS_VALIDATION_ENGINES = {"bigquery"}


class ValidateDatabaseParametersCommand(BaseCommand):
Expand Down
26 changes: 24 additions & 2 deletions superset/db_engine_specs/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from typing_extensions import TypedDict

from superset.db_engine_specs.postgres import PostgresBaseEngineSpec
from superset.errors import SupersetError, SupersetErrorType
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.models.sql_lab import Query
from superset.utils import core as utils

Expand Down Expand Up @@ -233,7 +233,29 @@ def get_parameters_from_uri(
def validate_parameters(
cls, parameters: SnowflakeParametersType # pylint: disable=unused-argument
) -> List[SupersetError]:
return []
errors: List[SupersetError] = []
required = {
"host",
"warehouse",
"username",
"database",
"account",
"role",
"password",
}
present = {key for key in parameters if parameters.get(key, ())}
missing = sorted(required - present)

if missing:
errors.append(
SupersetError(
message=f'One or more parameters are missing: {", ".join(missing)}',
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"missing": missing},
),
)
return errors

@classmethod
def parameters_json_schema(cls) -> Any:
Expand Down