Drop columns in a dbt model

Hi there,

I have a macro that will add some extra columns to an existing model and performs some data cleansing as per business requirements.

After the data been cleansed, what is the best way to delete the unwanted columns?

Suppose an input data(model) may have millions of columns and we don’t care what are the other columns other than the known columns that are to be deleted.

Below code in a dbt model can select the columns in the list but I don’t know how to delete/not select the columns in the list. Any thoughts?

{% set columns_to_delete = ["column_1", "column_2", "column_3"] -%}

select 
    {% for column in columns_to_delete %}
        {{ column }},
    {% endfor %} 

I have checked that {% for column **not** in columns_to_delete %} is not working.

Thanks in advance :slight_smile: