Qasim Arthuna
Qasim Arthuna

Reputation: 11

Postgresql Query Error in DBT: Column Does Not Exist

I'm encountering an error when running the tempo.sql model:

{{ config(
    materialized='incremental',
    unique_key='Id'
) }}
SELECT 40 AS "Id", 
       'Moe Eggert' AS "Contact", 
       'M' AS "Sex", 
       35 AS "Age", 
       'PA' AS "State", 
       'I3593' AS "Product_ID", 
       'Desktop' AS "Product_Type", 
       399.99 AS "Sale Price", 
       72.09 AS "Profit", 
       'Website' AS "Lead", 
       'May' AS "Month", 
       2020 AS "Year"
FROM public.tempo;

The error message is:

column "id" does not exist
  LINE 8:                 select (Id)
                                  ^
  HINT:  Perhaps you meant to reference the column "tempo__dbt_tmp135333094832.Id" or the column "tempo.Id".

Here is the schema of the table:

CREATE TABLE public.tempo (
    "Id" int4 NULL,
    "Age" int4 NULL,
    "Sale Price" float4 NULL,
    "Profit" float4 NULL,
    "Year" int4 NULL,
    "Contact" varchar(256) NULL,
    "Sex" varchar(256) NULL,
    "State" varchar(256) NULL,
    "Product_ID" varchar(256) NULL,
    "Product_Type" varchar(256) NULL,
    "Lead" varchar(256) NULL,
    "Month" varchar(256) NULL
);

Additionally, when I run dbt commit && dbt run, it creates the following file in the run folder:

delete from "postgres"."public"."tempo"
where (
    Id) in (
    select (Id)
    from "tempo__dbt_tmp140716157689"
);

insert into "postgres"."public"."tempo" ("Id", "Age", "Sale Price", "Profit", "Year", "Contact", "Sex", "State", "Product_ID", "Product_Type", "Lead", "Month")
(
    select "Id", "Age", "Sale Price", "Profit", "Year", "Contact", "Sex", "State", "Product_ID", "Product_Type", "Lead", "Month"
    from "tempo__dbt_tmp140716157689"
)

Can anyone help me resolve this issue?

I tried to change

select (Id)

with

select ("Id")

But it gets overwritten when I rerun dbt run

Upvotes: 0

Views: 19

Answers (0)

Related Questions