Vitor-Avila commented on code in PR #30721:
URL: https://github.com/apache/superset/pull/30721#discussion_r1822797610


##########
superset/datasets/api.py:
##########
@@ -1179,13 +1185,22 @@ def render_item_list(item_list: list[dict[str, Any]]) 
-> list[dict[str, Any]]:
                 for item in item_list
             ]
 
-        if metrics := data.get("metrics"):
-            data["metrics"] = render_item_list(metrics)
+        item_type: str | None = None
+        try:
+            if metrics := data.get("metrics"):
+                item_type = "metric"
+                data["metrics"] = render_item_list(metrics)
 
-        if columns := data.get("columns"):
-            data["columns"] = render_item_list(columns)
+            if columns := data.get("columns"):
+                item_type = "column"
+                data["columns"] = render_item_list(columns)
 
-        if sql := data.get("sql"):
-            data["rendered_sql"] = processor.process_template(sql)
+            if sql := data.get("sql"):
+                item_type = "query"
+                data["rendered_sql"] = processor.process_template(sql)
+        except TemplateSyntaxError as ex:
+            raise SupersetTemplateException(
+                f"Unable to render expression from dataset {item_type}.",
+            ) from ex

Review Comment:
   That's cool! Let me implement this 🙏 



-- 
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]

Reply via email to