mirror of
https://github.com/apache/superset.git
synced 2026-04-23 10:04:45 +00:00
fix: show custom errors in SQL Lab (#14959)
* fix: show custom errors in SQL Lab * Fix lint * Fix test * Update superset/views/base.py Co-authored-by: ʈᵃᵢ <tai@apache.org> * Fix lint * Debug failing test * Remove print() * Debug flaky tests * Fix test Co-authored-by: ʈᵃᵢ <tai@apache.org>
This commit is contained in:
@@ -80,6 +80,10 @@ CONNECTION_HOST_DOWN_REGEX = re.compile(
|
||||
CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
|
||||
'database "(?P<database>.*?)" does not exist'
|
||||
)
|
||||
COLUMN_DOES_NOT_EXIST_REGEX = re.compile(
|
||||
r'postgresql error: column "(?P<column_name>.+?)" '
|
||||
r"does not exist\s+LINE (?P<location>\d+?)"
|
||||
)
|
||||
|
||||
|
||||
class PostgresBaseEngineSpec(BaseEngineSpec):
|
||||
@@ -100,7 +104,7 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
|
||||
"P1Y": "DATE_TRUNC('year', {col})",
|
||||
}
|
||||
|
||||
custom_errors = {
|
||||
custom_errors: Dict[Pattern[str], Tuple[str, SupersetErrorType, Dict[str, Any]]] = {
|
||||
CONNECTION_INVALID_USERNAME_REGEX: (
|
||||
__('The username "%(username)s" does not exist.'),
|
||||
SupersetErrorType.CONNECTION_INVALID_USERNAME_ERROR,
|
||||
@@ -139,6 +143,14 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
|
||||
SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR,
|
||||
{"invalid": ["database"]},
|
||||
),
|
||||
COLUMN_DOES_NOT_EXIST_REGEX: (
|
||||
__(
|
||||
'We can\'t seem to resolve the column "%(column_name)s" at '
|
||||
"line %(location)s.",
|
||||
),
|
||||
SupersetErrorType.COLUMN_DOES_NOT_EXIST_ERROR,
|
||||
{},
|
||||
),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user