You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by aa...@apache.org on 2022/06/24 17:53:53 UTC
[superset] 01/01: added explore_json error
This is an automated email from the ASF dual-hosted git repository.
aafghahi pushed a commit to branch arash/error_messages
in repository https://gitbox.apache.org/repos/asf/superset.git
commit d73504cf674deb407032617b8feadc28a8573f47
Author: AAfghahi <ar...@gmail.com>
AuthorDate: Fri Jun 24 13:53:31 2022 -0400
added explore_json error
---
superset/errors.py | 7 +++++++
superset/views/core.py | 11 +++++++++++
2 files changed, 18 insertions(+)
diff --git a/superset/errors.py b/superset/errors.py
index 9198a82d3f..44ad2477cd 100644
--- a/superset/errors.py
+++ b/superset/errors.py
@@ -90,6 +90,9 @@ class SupersetErrorType(str, Enum):
INVALID_PAYLOAD_FORMAT_ERROR = "INVALID_PAYLOAD_FORMAT_ERROR"
INVALID_PAYLOAD_SCHEMA_ERROR = "INVALID_PAYLOAD_SCHEMA_ERROR"
+ # Dataset/Datasource Errors
+ CHART_TYPE_REQUIRES_DATASET_ERROR = "CHART_TYPE_REQUIRES_DATASET_ERROR"
+
ISSUE_CODES = {
1000: _("The datasource is too large to query."),
@@ -140,6 +143,9 @@ ISSUE_CODES = {
1035: _("Failed to start remote query on a worker."),
1036: _("The database was deleted."),
1037: _("Custom SQL fields cannot contain sub-queries."),
+ 1038: _(
+ "This chart type is not supported when using an unsaved query as a chart source."
+ ),
}
@@ -177,6 +183,7 @@ ERROR_TYPES_TO_ISSUE_CODES_MAPPING = {
SupersetErrorType.ASYNC_WORKERS_ERROR: [1035],
SupersetErrorType.DATABASE_NOT_FOUND_ERROR: [1011, 1036],
SupersetErrorType.CONNECTION_DATABASE_TIMEOUT: [1001, 1009],
+ SupersetErrorType.CHART_TYPE_REQUIRES_DATASET_ERROR: [1038],
}
diff --git a/superset/views/core.py b/superset/views/core.py
index 42b99a3f11..13c7bce58e 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -636,6 +636,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
status=403,
)
+ print("I am in explore json")
form_data = get_form_data()[0]
try:
datasource_id, datasource_type = get_datasource_info(
@@ -643,6 +644,16 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
)
force = request.args.get("force") == "true"
+ if datasource_type == "query":
+ raise SupersetErrorException(
+ SupersetError(
+ message=__(
+ "This chart type is not supported when using an unsaved query as a chart source. Create a dataset to visualize your data."
+ ),
+ error_type=SupersetErrorType.DML_NOT_ALLOWED_ERROR,
+ level=ErrorLevel.ERROR,
+ )
+ )
# TODO: support CSV, SQL query and other non-JSON types
if (
is_feature_enabled("GLOBAL_ASYNC_QUERIES")