On Postgres 16.0, the Load Data Warehouse (DWH) incremental job can fail with "syntax error" if certain tables are updated.
It fails with the below error message:
ERROR 2021-11-30 13:53:24,648 [Thread-33113] dwh.event Merge - PFM_INVESTMENT - An error occurred executing this job entry :
Couldn't execute SQL: DO $$
DECLARE
V_SQL_TEXT text;
V_EXCEPTION varchar(4000);
V_SQLERRM varchar(4000);
V_SQLSTATE varchar(5);
BEGIN
V_SQL_TEXT := 'INSERT INTO DWH_PFM_INVESTMENT_MAPPING SELECT CLARITY_CREATED_DATE AS CLARITY_CREATED_DATE, CLARITY_PORTFOLIO_KEY AS CLARITY_PORTFOLIO_KEY, LAST_UPDATED_DATE AS CLARITY_UPDATED_DATE, INVESTMENT_ID AS INVESTMENT_ID, INVESTMENT_KEY AS INVESTMENT_KEY, INVESTMENT_NAME AS INVESTMENT_NAME, PORTFOLIO_ID AS PORTFOLIO_ID, PORTFOLIO_KEY AS PORTFOLIO_KEY, PORTFOLIO_NAME AS PORTFOLIO_NAME, TO_TIMESTAMP('30-nov-2021 13:53:19', 'dd-mon-yyyy hh24:mi:ss') AS dw_updated_date FROM DWH_PFM_INVESTMENT_MAPPING_V A WHERE LAST_UPDATED_DATE >= TO_TIMESTAMP('30-nov-2021 13:41:57', 'dd-mon-yyyy hh24:mi:ss') AND LAST_UPDATED_DATE <= (SELECT DISTINCT dwh_dim_start_date FROM dwh_cfg_settings) ON CONFLICT (PORTFOLIO_KEY, INVESTMENT_KEY) DO UPDATE SET CLARITY_PORTFOLIO_KEY = EXCLUDED.CLARITY_PORTFOLIO_KEY, ' ||
'PORTFOLIO_ID = EXCLUDED.PORTFOLIO_ID, PORTFOLIO_NAME = EXCLUDED.PORTFOLIO_NAME, INVESTMENT_ID = EXCLUDED.INVESTMENT_ID, INVESTMENT_NAME = EXCLUDED.INVESTMENT_NAME, ' ||
'CLARITY_CREATED_DATE = EXCLUDED.CLARITY_CREATED_DATE, CLARITY_UPDATED_DATE = EXCLUDED.CLARITY_UPDATED_DATE, DW_UPDATED_DATE = EXCLUDED.DW_UPDATED_DATE';
EXECUTE V_SQL_TEXT;
EXCEPTION
WHEN OTHERS THEN
BEGIN
V_SQLSTATE := SQLSTATE;
V_SQLERRM := SQLERRM;
V_SQL_TEXT := 'INSERT INTO DWH_PFM_INVESTMENT_MAPPING SELECT CLARITY_CREATED_DATE AS CLARITY_CREATED_DATE, CLARITY_PORTFOLIO_KEY AS CLARITY_PORTFOLIO_KEY, LAST_UPDATED_DATE AS CLARITY_UPDATED_DATE, INVESTMENT_ID AS INVESTMENT_ID, INVESTMENT_KEY AS INVESTMENT_KEY, INVESTMENT_NAME AS INVESTMENT_NAME, PORTFOLIO_ID AS PORTFOLIO_ID, PORTFOLIO_KEY AS PORTFOLIO_KEY, PORTFOLIO_NAME AS PORTFOLIO_NAME, TO_TIMESTAMP(**30-nov-2021 13:53:19**, **dd-mon-yyyy hh24:mi:ss**) AS dw_updated_date FROM DWH_PFM_INVESTMENT_MAPPING_V A WHERE LAST_UPDATED_DATE >= TO_TIMESTAMP(**30-nov-2021 13:41:57**, **dd-mon-yyyy hh24:mi:ss**) AND LAST_UPDATED_DATE <= (SELECT DISTINCT dwh_dim_start_date FROM dwh_cfg_settings) ON CONFLICT (PORTFOLIO_KEY, INVESTMENT_KEY) DO UPDATE SET CLARITY_PORTFOLIO_KEY = EXCLUDED.CLARITY_PORTFOLIO_KEY, ' ||
'PORTFOLIO_ID = EXCLUDED.PORTFOLIO_ID, PORTFOLIO_NAME = EXCLUDED.PORTFOLIO_NAME, INVESTMENT_ID = EXCLUDED.INVESTMENT_ID, INVESTMENT_NAME = EXCLUDED.INVESTMENT_NAME, ' ||
'CLARITY_CREATED_DATE = EXCLUDED.CLARITY_CREATED_DATE, CLARITY_UPDATED_DATE = EXCLUDED.CLARITY_UPDATED_DATE, DW_UPDATED_DATE = EXCLUDED.DW_UPDATED_DATE';
V_EXCEPTION := 'ENCOUNTERED EXCEPTION WHILE INSERTING INTO DWH_PFM_INVESTMENT_MAPPING. ' || V_SQLERRM;
ROLLBACK;
BEGIN
INSERT INTO DWH_CMN_ERROR_MESSAGE VALUES('DWH_PFM_INVESTMENT_MAPPING', V_EXCEPTION, V_SQLSTATE,REPLACE(V_SQL_TEXT,'**',''''));
END;
COMMIT;
RAISE EXCEPTION '%', V_EXCEPTION;
END;
COMMIT;
END $$;
ERROR: syntax error at or near "30"
Position: 546
Release : 16.0
Component : CLARITY DATA WAREHOUSE
Database: PostgreSQL
This has been reported as DE63317.
On Premise: Fixed in 16.0.1 and patch 16.0.0.1.
GCP: The fix has been applied as a prepatch in SAAS environments as Defect DE63317.
Run the Full Load of the Load Data Warehouse job for now.