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

[bug] sql_header and contract enforcement causes adapter syntax erorrs #515

Open
rchui opened this issue Feb 18, 2025 · 1 comment
Open

Comments

@rchui
Copy link

rchui commented Feb 18, 2025

Using contract enforcement and setting a sql_header can cause the DuckDB adapter to encounter errors when it attempts to describe the structure of a query because the sql_header is included when it shouldn't be.

For example it attempts to run:

# dbt_project.yml
    +sql_header: |
        set pg_connection_limit = 3 ;
        set threads = 2 ;
DESCRIBE (set pg_connection_limit = 3 ;
set threads = 2 ;select * from (
        

select *, current_timestamp::timestamptz as updated_at

Which results in the error:

  Parser Error: syntax error at or near "set"

Instead the adapter should not be inserting sql_header into the top of the query it is attempting to describe. You can work around this with:

    +sql_header: |
      {% if execute %}
        set pg_connection_limit = 3 ;
        set threads = 2 ;
      {% endif %}
@rchui
Copy link
Author

rchui commented Feb 19, 2025

Correction: the workaround does not work. It just removes the sql_header.

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

1 participant