CREATE MATERIALIZED VIEW insights.benchmark_values_by_currency_mv
WITH (
backfill_order=FIXED(asset_service.assets_dm_next -> asset_service.benchmark_constituents_ft, asset_service.benchmarks_dm -> asset_service.benchmark_constituents_ft)
) AS
SELECT
c.benchmark_id,
c.date AS fact_date,
a.issue_currency_code AS currency_code,
SUM(c.weight) AS weight
FROM asset_service.benchmark_constituents_ft AS c
JOIN asset_service.assets_dm AS a
ON a.id = c.asset_id
JOIN asset_service.benchmarks_dm AS b
ON b.id = c.benchmark_id
WHERE
b.disabled_at IS NULL AND NOT a.issue_currency_code IS NULL
GROUP BY
c.benchmark_id,
c.date,
a.issue_currency_code