Upon configuration of dynamic lookup, load data warehouse is failing with below errors
duplicate key value violates unique constraint "dwh_lkp_XX_XX_XX_dyn_u1"
Clarity 16.4.1
The failure occurred during a "Full Insert" operation into the DWH_LKP_XX_XXX_XXX_DYN table. The process attempted to insert data from the source view DWH_LKP_XX_XXX_XXX_DYN_V, but this view returned duplicate records for a set of columns governed by a unique index (typically the lookup code and language combination)
In Clarity PPM, tables ending in _DYN are used for dynamic lookups. This error indicates that the underlying NSQL query for the dynamic lookup associated with DWH_LKP_XX_XXX_XXX_DYN is returning more than one row for the same lookup code per language. Because the Data Warehouse requires these codes to be unique, the job fails when it encounters duplicates.
Recommended Actions
Best Practice for writing NSQL Lookup for DWH: To prevent unique constraint violations (like the one in your log) and ensure your dynamic lookups function correctly in the Data Warehouse (DWH), you should follow these specific NSQL coding standards.
SELECT @SELECT:DIM:USER_DEF:IMPLIED:REQ:r.status_code:ID@, -- Hidden ID
@SELECT:DIM_PROP:USER_DEF:IMPLIED:REQ:r.status_name:NAME@, -- Display Name @SELECT:DIM_PROP:USER_DEF:IMPLIED:REQ:r.last_updated_date:LAST_UPDATED_DATE@, -- Mandatory
@SELECT:DIM_PROP:USER_DEF:IMPLIED:REQ:lang.language_code:LANGUAGE_CODE@, -- Mandatory for multi-lang
@SELECT:DIM_PROP:USER_DEF:IMPLIED:REQ:lang.id:LANGUAGE_ID@ -- Recommended
FROM my_custom_status_table r JOIN cmn_languages lang
ON r.language_id = lang.id WHERE r.is_active = 1 AND
@FILTER@
AND lang.language_code = @WHERE:PARAM:LANGUAGE@ -- Ensures the query only returns the current session's language