CREATE SINK insights.flow_by_currency_sink AS
SELECT
account_group_id,
dim_transaction_date,
position_type AS type,
holding_currency_code,
currency_code,
adjusted_net_flow,
adjusted_net_flow_system_currency,
cumulative_adjusted_netflow
FROM insights.flow_by_currency_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_currencies_ft',
schema='insights',
type='upsert',
force_compaction='true',
primary_key='account_group_id,dim_transaction_date,holding_currency_code,type'
)