Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in incremental model using a field name called location #192

Open
YiftachLevy opened this issue Feb 23, 2024 · 2 comments
Open

Error in incremental model using a field name called location #192

YiftachLevy opened this issue Feb 23, 2024 · 2 comments

Comments

@YiftachLevy
Copy link

We have an incremental model with a filed name that called location.
It seems to be a reserved name in impala so we create the table with the following command:

,cast(s.`location` as string) `location`

This seems to work in impala but it fails in dbt while using incremental model because dbt an insert creates a script which use location without the quotes.

error:

11:58:34    Encountered: LOCATION
11:58:34    Expected: DEFAULT, IDENTIFIER
11:58:34    
11:58:34    CAUSED BY: Exception: Syntax error

Example from the compiled code

insert into table_name (location)
(select location from table_name__dbt_tmp)

Versions:
dbt-core 1.4.9
dbt-impala 1.4.0

@tovganesh
Copy link
Contributor

Apparently, "location" is a keyword in Impala: https://impala.apache.org/docs/build/html/topics/impala_reserved_words.html
Probably the solution would be to add quote to the fields.

@YiftachLevy
Copy link
Author

YiftachLevy commented Feb 26, 2024

Thank you for the quick answer.
Using the quotes works for normal tables:

    config(
        materialized='table'
    )

It fails however in incremental moldes

    config(
        materialized='incremental'
    )

The quotes are not passed in the select clause in the insert statement from the temp to the table

insert into table_name (location)
(select **location** from table_name__dbt_tmp)

Is there any workaroud/dbt-macro for passing the quotes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants