mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix: Annotation layer errors (#34074)
This commit is contained in:
committed by
GitHub
parent
ef14a5fbb4
commit
d6ed819fe2
@@ -186,9 +186,11 @@ class QueryContextProcessor:
|
||||
label_map.update(
|
||||
{
|
||||
column_name: [
|
||||
str(query_obj.columns[idx])
|
||||
if not is_adhoc_column(query_obj.columns[idx])
|
||||
else cast(AdhocColumn, query_obj.columns[idx])["sqlExpression"],
|
||||
(
|
||||
str(query_obj.columns[idx])
|
||||
if not is_adhoc_column(query_obj.columns[idx])
|
||||
else cast(AdhocColumn, query_obj.columns[idx])["sqlExpression"]
|
||||
),
|
||||
]
|
||||
for idx, column_name in enumerate(query_obj.column_names)
|
||||
}
|
||||
@@ -196,12 +198,22 @@ class QueryContextProcessor:
|
||||
label_map.update(
|
||||
{
|
||||
metric_name: [
|
||||
str(query_obj.metrics[idx])
|
||||
if not is_adhoc_metric(query_obj.metrics[idx])
|
||||
else str(cast(AdhocMetric, query_obj.metrics[idx])["sqlExpression"])
|
||||
if cast(AdhocMetric, query_obj.metrics[idx])["expressionType"]
|
||||
== "SQL"
|
||||
else metric_name,
|
||||
(
|
||||
str(query_obj.metrics[idx])
|
||||
if not is_adhoc_metric(query_obj.metrics[idx])
|
||||
else (
|
||||
str(
|
||||
cast(AdhocMetric, query_obj.metrics[idx])[
|
||||
"sqlExpression"
|
||||
]
|
||||
)
|
||||
if cast(AdhocMetric, query_obj.metrics[idx])[
|
||||
"expressionType"
|
||||
]
|
||||
== "SQL"
|
||||
else metric_name
|
||||
)
|
||||
),
|
||||
]
|
||||
for idx, metric_name in enumerate(query_obj.metric_names)
|
||||
if query_obj and query_obj.metrics
|
||||
@@ -901,13 +913,24 @@ class QueryContextProcessor:
|
||||
from superset.commands.chart.data.get_data_command import ChartDataCommand
|
||||
|
||||
if not (chart := ChartDAO.find_by_id(annotation_layer["value"])):
|
||||
raise QueryObjectValidationError(_("The chart does not exist"))
|
||||
raise QueryObjectValidationError(
|
||||
_(
|
||||
f"""Chart with ID {annotation_layer["value"]} (referenced by
|
||||
annotation layer '{annotation_layer["name"]}') was not found.
|
||||
Please verify that the chart exists and is accessible."""
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
if chart.viz_type in viz_types:
|
||||
if not chart.datasource:
|
||||
raise QueryObjectValidationError(
|
||||
_("The chart datasource does not exist"),
|
||||
_(
|
||||
f"""The dataset for chart ID {chart.id} (referenced by
|
||||
annotation layer '{annotation_layer["name"]}') was
|
||||
not found. Please check that the dataset exists and
|
||||
is accessible."""
|
||||
)
|
||||
)
|
||||
|
||||
form_data = chart.form_data.copy()
|
||||
@@ -924,7 +947,12 @@ class QueryContextProcessor:
|
||||
|
||||
if not (query_context := chart.get_query_context()):
|
||||
raise QueryObjectValidationError(
|
||||
_("The chart query context does not exist"),
|
||||
_(
|
||||
f"""The query context for chart ID {chart.id} (referenced
|
||||
by annotation layer '{annotation_layer["name"]}') was not found.
|
||||
Please ensure the chart is properly configured and has a valid
|
||||
query context."""
|
||||
)
|
||||
)
|
||||
|
||||
if overrides := annotation_layer.get("overrides"):
|
||||
|
||||
Reference in New Issue
Block a user