CREATE SINK insights.flow_by_asset_sink AS
SELECT
account_group_id,
dim_transaction_date,
position_type AS type,
asset_id,
currency_code,
adjusted_net_flow,
adjusted_net_flow_system_currency,
adjusted_net_flow_asset_currency,
cumulative_adjusted_netflow,
cumulative_adjusted_netflow_asset_currency
FROM insights.flow_by_asset_mv
WITH (
connector='postgres',
host='psql-nonprod-uae-derived.postgres.database.azure.com',
port='6432',
user='migration_user',
password='***',
database='adib-int-insights-db',
table='account_group_transactions_by_assets_ft',
schema='insights',
type='upsert',
force_compaction='true',
primary_key='account_group_id,dim_transaction_date,asset_id,type'
)