CREATE SINK insights.benchmark_values_by_asset_sink AS
SELECT
c.benchmark_id,
c.date AS fact_date,
c.asset_id,
c.weight
FROM asset_service.benchmark_constituents_ft AS c
JOIN asset_service.benchmarks_dm AS b
ON b.id = c.benchmark_id
WHERE
b.disabled_at IS NULL
WITH (
connector='postgres',
host='psql-nonprod-uae-derived.postgres.database.azure.com',
port='6432',
user='migration_user',
password='***',
database='alinma-int-insights-db',
table='benchmark_values_by_assets_ft',
schema='insights',
type='upsert',
force_compaction='true',
primary_key='benchmark_id,fact_date,asset_id'
)