Search code examples
snowflake-cloud-data-platformdbt

selecting a column name "delete" in the dbt query to create a VIEW


I am trying to create a VIEW in dbt. The source table has a column named delete. How do I select this column in the select query in DBT?

I tried :

select id, delete from src_table;
select id, "delete" from src_table;
select id, "DELETE" from src_table;
select id, DELETE from src_table;

but neither of them worked. Please advise.


Solution

  • A colleague helped figure this out. In addition to having the delete in double quotes, need to have a model YAML as following:

    version: 2
    
    models:
      - name: model_name
        columns:
          - name: delete
            quote: true
    

    once this yaml definition is created, select id, "delete" from src_table should work.