code: def dataset_macro(
      dataset_id: int,
      include_metrics: bool = False,
      columns: Optional[list[str]] = None,
      from_dttm: Optional[datetime] = None,
      to_dttm: Optional[datetime] = 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.
  
      The from_dttm and to_dttm parameters are filled in from filter values in explore
      views, and we take them to make those properties available to jinja templates in
      the underlying dataset.
      """
      # pylint: disable=import-outside-toplevel
      from superset.daos.dataset import DatasetDAO
  
      dataset = DatasetDAO.find_by_id(dataset_id)
      if not dataset:
          raise DatasetNotFoundError(f"Dataset {dataset_id} not found!")
  
      columns = columns or [
          column.column_name for column in dataset.columns
      ]
      metrics = [metric.metric_name for metric in dataset.metrics]
      query_obj = {
          "is_timeseries": False,
          "filter": [],
          "metrics": metrics if include_metrics else None,
          "columns": columns,
          "from_dttm": from_dttm,
          "to_dttm": to_dttm,
      }
      sqla_query = dataset.get_query_str_extended(
          query_obj, mutate=False
      )
      sql = sqla_query.sql
      return f"(\n{sql}\n) AS dataset_{dataset_id}"
  
imports: import json
  import re
  from datetime import datetime
  from functools import lru_cache, partial
  from typing import Any, Callable, cast, Optional, TYPE_CHECKING, TypedDict, Union
  import dateutil
  from flask import current_app, g, has_request_context, request
  from flask_babel import gettext
  from jinja2 import DebugUndefined
  from jinja2.sandbox import SandboxedEnvironment
  from sqlalchemy.engine.interfaces import Dialect
  from sqlalchemy.sql.expression import bindparam
  from sqlalchemy.types import String
  from superset.commands.dataset.exceptions import DatasetNotFoundError
  from superset.constants import LRU_CACHE_MAX_SIZE
  from superset.exceptions import SupersetTemplateException
  from superset.extensions import feature_flag_manager
  from superset.utils.core import convert_legacy_filters_into_adhoc, get_user_id, merge_extra_filters
label_desc: Use image node_id 7 for calling a global function with example usage: dataset_macro(dataset_id, include_metrics, columns, from_dttm, to_dttm) and returns: str, sql, str, dataset_id