{# Spec 154 v3 - materialization section rendered on the opportunity detail page. Fires when one or more of this table's opportunities carries a materialization payload - either an audit-detected candidate (``materialization_candidate``, possibly with any of the four strategies below) or Google's MV Recommender pass-through (``bq_materialization_recommendation``). The audit-detected card branches on ``recommended_strategy``: * ``materialized_view`` - full MV card with generated SQL tabs and the stat strip (cost / executions / avg bytes). * ``ephemeral`` - inline-as-CTE card with the dbt node id + the downstream models that would absorb the inline. * ``table`` - persist-as-table card with build vs. read counts. * ``incremental`` - switch-to-incremental card with the representative build SQL so the user can see the filter the fitter matched. Inputs from the route: ``audit_mv_candidates`` - list of evidence_snapshot dicts (one per audit-detected opportunity on this table); each carries a ``recommended_strategy`` field. ``bq_mv_recommendations`` - list of dicts (BQ Recommender rows) each with: target_resource, target_table_full_name, bq_description, bq_recommendation_state, bq_insights[], last_refresh_time Renders nothing when both lists are empty, so the partial can be included unconditionally from detail.html. #} {% macro strategy_pill(strategy) %} {%- if strategy == "ephemeral" -%} ephemeral {%- elif strategy == "incremental" -%} incremental {%- elif strategy == "table" -%} table {%- elif strategy == "materialized_view" -%} materialized view {%- else -%} {{ strategy or "unspecified" }} {%- endif -%} {% endmacro %} {% macro strategy_heading(strategy) %} {%- if strategy == "ephemeral" -%} Inline this model {%- elif strategy == "incremental" -%} Switch to incremental {%- elif strategy == "table" -%} Keep this persisted as a table {%- elif strategy == "materialized_view" -%} Create a materialized view {%- else -%} Review materialization {%- endif -%} {% endmacro %} {% macro strategy_summary(strategy) %} {%- if strategy == "ephemeral" -%} Remove the persisted intermediate table and let the downstream model absorb the SQL as a CTE. {%- elif strategy == "incremental" -%} Avoid rebuilding the full table when the query shape supports processing only new or changed rows. {%- elif strategy == "table" -%} Keep the table materialized because reads justify the storage and rebuild cost. {%- elif strategy == "materialized_view" -%} Cache the query result behind BigQuery refresh semantics when the repeated query pattern is stable. {%- else -%} Review the evidence before changing how this object is persisted. {%- endif -%} {% endmacro %} {% macro candidate_header(strategy, source_label, object_label=None, state=None) %}
{{ object_label }}
{% endif %}Evidence
{{ reasoning.observation }}
Action
{{ reasoning.recommendation }}
Impact
{{ reasoning.expected_benefit }}
Check
{{ caveats[0] }} {% if caveats | length > 1 %} +{{ caveats | length - 1 }} more {% endif %}
Consumers
{{ cand | tojson(indent=2) }}
{{ rec.bq_description }}
{% endif %} {% if rec.bq_insights %}Insights
Last refreshed by Google's Recommender: {{ rec.last_refresh_time }}
{% endif %}