{# Spec 148 — Recommended physical layout card(s). Read-only recommendation: no diff, no Apply button, no copyable ALTER. Renders a partition + cluster suggestion derived from how the table is actually queried in the cached scan window. ``layout_recommendations`` is a list of zero or more ``LayoutRecommendation`` objects — one per qualifying target table. For ``partition_pruning`` opportunities the targets are the upstream tables the bad query was reading from, NOT the downstream that the opportunity is anchored to. The ``{% for %}`` loop renders one card per target; an empty list produces zero markup. #} {% for layout_recommendation in (layout_recommendations or []) %}

Recommended physical layout

{% if layout_recommendation.table %} {{ layout_recommendation.table }} {% endif %}

Based on how this table's data is queried across the scan window. Audit doesn't modify your SQL — apply the recommendation manually via ALTER TABLE … SET OPTIONS(...) or in your dbt model config.

{% if layout_recommendation.partition %}

Partition by {{ layout_recommendation.partition.column }} {{ layout_recommendation.partition.column_type }}

{{ "%.0f" | format(layout_recommendation.partition.filter_frequency * 100) }}% of consumer queries ({{ layout_recommendation.partition.consumer_job_count }} jobs in window) filter on this column. Table is currently {% if layout_recommendation.evidence.is_partitioned %}partitioned by another column{% else %}unpartitioned{% endif %}{% if layout_recommendation.evidence.total_bytes %}, {{ layout_recommendation.evidence.total_bytes | format_bytes }} total{% endif %}.

{% endif %} {% if layout_recommendation.cluster %}

Cluster on ({% for c in layout_recommendation.cluster %}{{ c.column }}{% if not loop.last %}, {% endif %}{% endfor %})

Top column appears in {{ "%.0f" | format(layout_recommendation.cluster[0].filter_or_join_frequency * 100) }}% of WHERE / JOIN clauses across {{ layout_recommendation.evidence.total_consumer_jobs }} consumer queries. {% if layout_recommendation.cluster | length > 1 %} Cluster ordering matters in BigQuery — listed columns are ordered by usage frequency descending. {% endif %}

{% endif %}

No SQL diff is generated for partition / cluster — these are physical-layout properties, not query rewrites. Audit surfaces the recommendation; you apply it.

{% endfor %}