CREATE SINK insights.flow_by_region_sink AS
SELECT
account_group_id,
dim_transaction_date,
position_type AS type,
item_id AS region_label_id,
currency_code,
adjusted_net_flow,
adjusted_net_flow_system_currency,
cumulative_adjusted_netflow
FROM insights.flow_by_distribution_mv
WHERE
distribution_type = 'regions'
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_regions_ft',
schema='insights',
type='upsert',
force_compaction='true',
primary_key='account_group_id,dim_transaction_date,region_label_id,type'
)