{% if _dataset %}{{ _dataset }}.{% endif %}{{ row.dbt_model_name or _table }}{% endset %}
{% call header_card(_title) %}
{# Build vs consumption - same classification the dashboard uses
(build = writes a destination; consumption = read-only). Makes it
explicit on the detail page which kind of workload this is. #}
{% if row.query_workload_kind in ['build', 'consumption'] %}
{{ 'Build' if row.query_workload_kind == 'build' else 'Consumption' }}
{% endif %}
{% if row.dbt_model_name %}
dbt
{% endif %}
{% if row.author_email %}
{{ row.author_email }}
{% endif %}
{# Spec 156 - origin chip in the header. Mirrors the Origin column
on /opportunities. Click filters the workspace to this origin.
Suppress it when it would just duplicate the green "dbt" marker
above (origin 'dbt' on a dbt model) - keep it for Looker / Hex /
Fivetran / etc. where it adds information. #}
{% if row.origin_tool and row.origin_tool != 'ad_hoc' and not (row.origin_tool == 'dbt' and row.dbt_model_name) %}
{{ row.origin_tool | replace('_', ' ') }}
{% endif %}
{% endcall %}
{# Three-card stat strip. Each card shows the AGGREGATED figure large,
with the latest execution's value on the small meta line beneath -
collapses the old six-card strip into one scannable row. #}
{% from "components/_stat_card.html" import stat_card %}
{%- set _runs = row.execution_count or 1 -%}
{%- set _runs_prefix = (_runs ~ " runs · ") if _runs > 1 else "" -%}
{%- set _last_ts = latest_job.creation_time.strftime("%Y-%m-%d %H:%M UTC") if (latest_job and latest_job.creation_time) else "" -%}
{%- set _agg_bytes = row.aggregated_bytes_processed or (job.total_bytes_processed if job else none) -%}
{%- set _agg_slot_ms = row.aggregated_slot_time_ms or (job.total_slot_ms if job else none) -%}
{%- set _cost_meta = (
_runs_prefix ~ "last " ~ ((latest_job.total_cost or 0) | float | format_usd) ~ ((" · " ~ _last_ts) if _last_ts else "")
) if latest_job else (("across " ~ _runs ~ " executions") if _runs > 1 else None) -%}
{%- set _bytes_meta = (
"last " ~ (latest_job.total_bytes_processed | format_bytes) ~ ((" · billed " ~ (latest_job.total_bytes_billed | format_bytes)) if latest_job.total_bytes_billed is not none else "")
) if (latest_job and latest_job.total_bytes_processed is not none) else None -%}
{%- set _slot_meta = (
"last " ~ ("%.1f" | format((latest_job.total_slot_ms or 0) / 3600000)) ~ " hrs" ~ ((" · " ~ (latest_job.duration_ms | format_duration)) if latest_job.duration_ms is not none else "")
) if (latest_job and latest_job.total_slot_ms is not none) else None -%}
{{ issue.row.explanation }}
{% if issue.rule_meta and issue.rule_meta.description %}{{ issue.rule_meta.description }}
{% endif %} {% if issue.template_result %}{{ issue.template_result.explanation }}
{% if issue.diff_lines %}Recommendations available below.
{% endif %} {% elif improvements %}Recommendations available below.
{% else %}No single-query SQL rewrite is available for this issue type. The fix is typically at the workload-scheduling, slot-reservation, or schema layer.
{% if layout_chip_targets %}Partition / cluster recommendations are available - see the chips above.
{% endif %} {% endif %}{{ imp.explanation }}
{% endif %} {% if imp.diff_lines or imp.before_content %}No diff available - template did not produce a change.
{% endif %}{{ imp.rollback }}
{% for line in job.query.split('\n') %}{{ loop.index }}{{ line }}
{% endfor %}