I’m trying to do the following :
{{ dbt_utils.generate_surrogate_key(
[ NVL ( column1, string_to_number ( column2))]
)
}}
The reason behind this is that column2 is a number but in VARCHAR format ( this is how it is coming from the source system) E.g : ‘0001’ and I want to have it as 1 .
String_to_number is a macro that I created and it’s doing the following :
CASE WHEN len(column)=0 THEN NULL ELSE TO_NUMBER(column) END.
Before descovering the fact that column2 is a number in a varchar format, this piece of code looked like this :
{{ dbt_utils.generate_surrogate_key ( [ "NVL(column1, column2)"})}} and it worked perfectly fine.
I really don’t know how to write it in the right way or if this is even possible.
Thank you!