EXECUTE IMMEDIATE requires the parameter to either be a string or a variable. You are trying to pass an expression through, causing the error. I believe that if you set up a SET VAR with the expression and then pass that through, that should solve yo...
Without VAR, the SET command attempts to set a Spark session configuration instead.DECLARE claim_year STRING;
SET VAR claim_year = (
SELECT CAST(CLAIM_YEAR - 1 AS STRING)
FROM dbengineering_prod.claimscommercial.clms_commercial_ref_years R
WHERE R.A...