{# Spec 151 - table-level layout recommendations index. One row per qualifying table from the latest scan. Replaces the spec-148 per-opportunity card surface; the opportunity detail page now shows a chip linking to /recommendations/layout/. Index columns: - Table (clickable → detail page) - Current layout (chip: "partitioned" / "unpartitioned") - Recommended partition column (or "-") - Top cluster picks (chip list, up to 4) - Window cost (cost in scan window) #} {% extends "layout.html" %} {% block content %}

Partition & Cluster

{% if not has_latest_scan %}

No successful scan yet. Run a scan first - layout recommendations are derived from the workload the scan observes.

{% elif not recommendations %}

The latest scan didn't surface any tables that meet the layout-recommendation gates. This happens when:

Run a longer-lookback scan if you suspect there's signal we're missing.

{% else %}
{% for rec in recommendations %} {% set _row_href = '/recommendations/layout/' ~ (rec.table_full_name | urlencode) %} {% endfor %}
Table Current Recommended partition Recommended cluster Window cost Jobs
{{ rec.table_full_name }} {# "BQ only" pill marks rows that exist solely because Google's recommender flagged the table - the audit itself didn't analyze it (under size gates or sparse query history). Distinguishes them from audit+BQ rows whose cells just happen to be empty for other reasons. #} {% if rec.is_bq_only %} BQ only {% endif %}
{{ rec.table_total_bytes | format_bytes }}
{% if rec.is_bq_only %} {# Current state is unknown for BQ-only rows - the audit didn't query the table's schema. Avoid rendering a definitive "unpartitioned" chip. #} unknown {% elif rec.is_currently_partitioned %} partitioned {% else %} unpartitioned {% endif %} {% if rec.recommended_partition_column %} {{ rec.recommended_partition_column }} {% elif rec.is_bq_only and rec.bq_columns %} {# Surface BQ's first column as the partition pick on BQ-only rows. Approximate - Google's recommender doesn't strictly distinguish partition vs cluster in its column list - but better than rendering "-". #} {{ rec.bq_columns[0] }} {% else %} - {% endif %} {% if rec.cluster_picks %}
{% for col in rec.cluster_picks %} {{ col }} {% endfor %}
{% elif rec.is_bq_only and rec.bq_columns | length > 1 %}
{% for col in rec.bq_columns[1:5] %} {{ col }} {% endfor %}
{% else %} - {% endif %}
{{ rec.table_total_cost_in_window_usd | format_usd }} {{ rec.contributing_job_count }}
{# Layout recommendations are one row per table by definition (the table-level partition / cluster pick). #} {% with pagination_item_noun = "tables" %} {% include "components/_pagination.html" %} {% endwith %} {% endif %} {% endblock %}