COUNTRIES

The COUNTRIES table contains description data for countries.

Column Name Type Not Null Cube Field Default Value1 Description
AS_OF_DATE DATE Y Timestamp (at close of business) for the data.
COUNTRY_CODE STRING Y N/A Unique three-letter country identifier code.
COUNTRY STRING Y N/A The name of the country.
LATITUDE DOUBLE Y N/A The latitude of the country in the decimal degrees format.
LONGITUDE DOUBLE Y N/A The longitude of the country in the decimal degrees format.
REGION STRING Y N/A The region in which the country is located.
SUB_REGION STRING Y N/A The sub-region in which the country is located.

Unique Key

Columns
AS_OF_DATE
COUNTRY_CODE

Incoming Joins

Source Table Source Columns Target Columns
COUNTERPARTIES AS_OF_DATE
COUNTRY_OF_ADDRESS
AS_OF_DATE
COUNTRY_CODE
COUNTERPARTIES AS_OF_DATE
COUNTRY_OF_RISK
AS_OF_DATE
COUNTRY_CODE

Table creation script

Snowflake

Table creation

create OR REPLACE stage MR_INPUT_RAW;

create OR REPLACE table COUNTRIES( AS_OF_DATE DATE NOT NULL, COUNTRY_CODE STRING NOT NULL DEFAULT 'N/A', REGION STRING NOT NULL DEFAULT 'N/A', SUB_REGION STRING NOT NULL DEFAULT 'N/A', COUNTRY STRING NOT NULL DEFAULT 'N/A', LATITUDE STRING NOT NULL DEFAULT 'N/A', LONGITUDE STRING NOT NULL DEFAULT 'N/A', primary key (AS_OF_DATE, COUNTRY_CODE) );

Table population from files (optional)

If you want to populate the table from CSV files, you can run the following scripts (this example assumes that you want to load the files Countries.csv present in the folders 2023-09-26, 2023-09-27 and 2023-09-28):

create OR REPLACE file format CSV_GZIP
	TYPE = CSV
    COMPRESSION = GZIP
    SKIP_HEADER = 1
    comment = 'File format to import MR data';

create OR REPLACE file format CSV_FORMAT TYPE = CSV COMPRESSION = AUTO SKIP_HEADER = 1 comment = 'File format to import MR data';

PUT file://<full path to you data folder>/2023-09-26/Countries.csv @MR_INPUT_RAW/2023-09-26; PUT file://<full path to you data folder>/2023-09-27/Countries.csv @MR_INPUT_RAW/2023-09-27; PUT file://<full path to you data folder>/2023-09-28/Countries.csv @MR_INPUT_RAW/2023-09-28;

copy into COUNTRIES from ( select $1, $2, ifnull($3, 'N/A'), ifnull($4, 'N/A'), ifnull($5, 'N/A'), ifnull($6, 'N/A'), ifnull($7, 'N/A') from @MR_INPUT_RAW (pattern => './Countries..csv.gz' , FILE_FORMAT => 'CSV_GZIP'));


  1. If the default value is marked as empty, it means that the default value is 'null' for nullable fields, and that a value needs to be explicitly set for non-nullable fields.  ↩︎