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

[V1.3.latest] Added ability OPTION clause when creating a table #460

Open
wants to merge 3 commits into
base: v1.3.latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### v1.3.2

#### Features
- Allow setting table `OPTIONS` using `config`

#### Fixes

* Install a correct version of `dbt-core` that is compatible with the library
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% macro sqlserver__create_table_as(temporary, relation, sql) -%}
{%- set as_columnstore = config.get('as_columnstore', default=true) -%}
{%- set option_clause = config.get('option_clause') -%}
{%- set sql_header = config.get('sql_header') -%}
{% set tmp_relation = relation.incorporate(
path={"identifier": relation.identifier.replace("#", "") ~ '_temp_view'},
type='view')-%}
Expand All @@ -13,14 +15,21 @@
EXEC('create view {{ tmp_relation.include(database=False) }} as
{{ temp_view_sql }}
');

{% if sql_header %}
{{ sql_header }}
{% endif %}

SELECT * INTO {{ relation }} FROM
{{ tmp_relation }}
{% if option_clause %}
OPTION( {{ option_clause }} )
{% endif %}

{{ sqlserver__drop_relation_script(tmp_relation) }}

{% if not temporary and as_columnstore -%}
{{ sqlserver__create_clustered_columnstore_index(relation) }}
{% endif %}

{% endmacro %}
{% endmacro %}