Complier error in Hooks with strings

The problem I’m having

I am adding a pre-hook in the config block of my model which deletes rows based on a filter. The filter is like:
pre-hook = ’ DELETE FROM TABLE WHERE = ‘Y’ ’
The error I am getting is 000904 (42000): SQL compilation error: error line 5 at position 30
invalid identifier ‘Y’

What I’ve already tried

Putting double single quotes around Y
putting braces like ‘’{{ “Y” }}‘’

Some example code

{{ config(
    materialized = 'incremental',
    unique_key = 'key',
    incremental_strategy = 'delete+insert',
    on_schema_change = 'sync-all-columns',
    pre_hook = ' DELETE FROM TABLE WHERE <COLUMN> = 'Y' '
)}}

Try

{{ config(
    materialized = 'incremental',
    unique_key = 'key',
    incremental_strategy = 'delete+insert',
    on_schema_change = 'sync-all-columns',
    pre_hook = "DELETE FROM TABLE WHERE <COLUMN> = 'Y' "
)}}

Using only single commas makes the compiler think that the string ended after the equals sign

This worked, thank you!

Awesome! Could you mark the answer as solution? To close the topic

Thanks!! :grin:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.