eschutho commented on code in PR #32228:
URL: https://github.com/apache/superset/pull/32228#discussion_r1953518391
##########
superset/jinja_context.py:
##########
@@ -908,16 +929,32 @@ def metric_macro(metric_key: str, dataset_id:
Optional[int] = None) -> str:
dataset = DatasetDAO.find_by_id(dataset_id)
if not dataset:
raise DatasetNotFoundError(f"Dataset ID {dataset_id} not found.")
+
metrics: dict[str, str] = {
metric.metric_name: metric.expression for metric in dataset.metrics
}
- dataset_name = dataset.table_name
- if metric := metrics.get(metric_key):
- return metric
- raise SupersetTemplateException(
- _(
- "Metric ``%(metric_name)s`` not found in %(dataset_name)s.",
- metric_name=metric_key,
- dataset_name=dataset_name,
+ if metric_key not in metrics:
+ raise SupersetTemplateException(
+ _(
+ "Metric ``%(metric_name)s`` not found in %(dataset_name)s.",
+ metric_name=metric_key,
+ dataset_name=dataset.table_name,
+ )
)
- )
+
+ definition = metrics[metric_key]
+
+ env = SandboxedEnvironment(undefined=DebugUndefined)
Review Comment:
@betodealmeida is this SandboxedEnvironment intentional?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]