Vitor-Avila commented on code in PR #27582: URL: https://github.com/apache/superset/pull/27582#discussion_r1532342392
########## superset/jinja_context.py: ########## @@ -722,3 +723,69 @@ def dataset_macro( sqla_query = dataset.get_query_str_extended(query_obj, mutate=False) sql = sqla_query.sql return f"(\n{sql}\n) AS dataset_{dataset_id}" + + +def get_dataset_id_from_context(metric_key: str) -> int: + """ + Retrives the Dataset ID from the request context. + + :param metric_key: the metric key. + :returns: the dataset ID. + """ + # pylint: disable=import-outside-toplevel + from superset.daos.chart import ChartDAO + from superset.views.utils import get_form_data + + exc_message = _( + "Please specify the Dataset ID for the ``%(name)s`` metric in the Jinja macro.", + name=metric_key, + ) + if form_data := get_form_data()[0]: Review Comment: let me take a look on that -- 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: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org