Skip to content

Commit

Permalink
sqlite write issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nintorac committed Dec 1, 2023
1 parent 6209bdd commit 9034654
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions dbt/include/duckdb/macros/adapters.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@

{% macro duckdb__create_schema(relation) -%}
{%- call statement('create_schema') -%}
create schema if not exists {{ relation.without_identifier() }}
{% set sql %}
select type from duckdb_databases()
where database_name='{{ relation.database }}'
and type='sqlite'
{% endset %}
{% set results = run_query(sql) %}
{% if results|length == 0 %}
create schema if not exists {{ relation.without_identifier() }}
{% else %}
{% if relation.schema!='main' %}
{{ exceptions.raise_compiler_error(
"Schema must be 'main' when writing to sqlite "
~ "instead got " ~ relation.schema
)}}
{% endif %}
{% endif %}
{%- endcall -%}
{% endmacro %}

Expand Down

0 comments on commit 9034654

Please sign in to comment.