dbt-duckdb
dbt-duckdb copied to clipboard
[bug] sql_header and contract enforcement causes adapter syntax erorrs
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 %}