I am converting pl sql code to dbt. This code validates data based on certain rules and then raises exception if it fails.
I understand we can’t raise exceptions in dbt models, so i have created a macro and am using exceptions.raise_compiler_error within if block but its giving syntax error.
Code Snippet, If condition is giving error -
{% macro test_scenarios_macro(input_number) %}
{% set sql_statement %}
select count(1)
from table1
where column1 = ‘{{input_number}}’
{% endset %}
{%- set lkp_EMIS_SOURCE_ID = dbt_utils.get_single_value(sql_statement, default=“‘NULL’”) -%}
{% if {{lkp_EMIS_SOURCE_ID}} == 6 %}
{{ exceptions.raise_compiler_error(“WRONG INPUT”) }}
{% endif %}
{% endmacro %}