betodealmeida commented on code in PR #15241:
URL: https://github.com/apache/superset/pull/15241#discussion_r887276835
##########
superset/jinja_context.py:
##########
@@ -602,3 +604,35 @@ def get_template_processor(
else:
template_processor = NoOpTemplateProcessor
return template_processor(database=database, table=table, query=query,
**kwargs)
+
+
+def dataset_macro(
+ dataset_id: int,
+ include_metrics: bool = False,
+ groupby: Optional[List[str]] = None,
+) -> str:
+ """
+ Given a dataset ID, return the SQL that represents it.
+
+ The generated SQL includes all columns (including computed) by default.
Optionally
+ the user can also request metrics to be included, and columns to group by.
+ """
+ # pylint: disable=import-outside-toplevel
+ from superset.datasets.dao import DatasetDAO
+
+ dataset = DatasetDAO.find_by_id(dataset_id)
+ if not dataset:
+ raise DatasetNotFoundError(f"Dataset {dataset_id} not found!")
+
+ columns = [column.column_name for column in dataset.columns]
+ metrics = [metric.metric_name for metric in dataset.metrics]
+ query_obj = {
+ "is_timeseries": False,
Review Comment:
If I remove this it will fail with:
```
superset.exceptions.QueryObjectValidationError: Datetime column not provided
as part table configuration and is required by this type of chart
```
So I'm leaving it for now.
--
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]