Understood, your jinja code cannot access row values, so you can’t see with jinja if you have a null value.
here is what you macro is doing:
- You pass an argument called
column_name
, which is a string - You assign this argument to the variable
column
- You check if the string you passed is none
- Your string is not none, is a string with the name of the column, so you fall into the else case and assign value to 1
- You return the number 1
When you call the macro in your model, it compiles it as 1
So, the jinja logic is being translated, but it not doing what you expect.
To check if you have null values in your column you should
- use a test
- if you want to store this information in a more persistent, detailed and custom way you can create another model referencing this one. Then you can use just normal SQL
- another option would be using dbt python models, but be sure it isn’t a much complex solution for this problem. Check if you can use the previous options