From efc0d443741b0efd6cc819101b2b8d83cdb41225 Mon Sep 17 00:00:00 2001 From: djagoda881 Date: Fri, 15 Dec 2023 13:39:45 +0100 Subject: [PATCH 1/3] [docs] Added description to CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83cd67e6..9639f4b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From c955f421bc26b657ad272982c1ce5ad463e6b5fa Mon Sep 17 00:00:00 2001 From: djagoda881 Date: Fri, 15 Dec 2023 13:44:46 +0100 Subject: [PATCH 2/3] [feature] Added ability to use OPTION clause when creating a table --- .../materializations/models/table/create_table_as.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql b/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql index 53bf7221..180d65a8 100644 --- a/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql +++ b/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql @@ -1,5 +1,6 @@ {% 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 tmp_relation = relation.incorporate( path={"identifier": relation.identifier.replace("#", "") ~ '_temp_view'}, type='view')-%} @@ -16,6 +17,9 @@ SELECT * INTO {{ relation }} FROM {{ tmp_relation }} + {% if option_clause %} + OPTION( {{ option_clause }} ) + {% endif %} {{ sqlserver__drop_relation_script(tmp_relation) }} @@ -23,4 +27,4 @@ {{ sqlserver__create_clustered_columnstore_index(relation) }} {% endif %} -{% endmacro %} +{% endmacro %} \ No newline at end of file From 6951140de21b1e927c0aec8ac067afb29bff7e3e Mon Sep 17 00:00:00 2001 From: Dominik Jagoda Date: Fri, 19 Jan 2024 17:50:39 +0100 Subject: [PATCH 3/3] [feature] Added `sql header` to `config` --- .../macros/materializations/models/table/create_table_as.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql b/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql index 180d65a8..826beb5e 100644 --- a/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql +++ b/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql @@ -1,6 +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')-%} @@ -14,6 +15,10 @@ EXEC('create view {{ tmp_relation.include(database=False) }} as {{ temp_view_sql }} '); + + {% if sql_header %} + {{ sql_header }} + {% endif %} SELECT * INTO {{ relation }} FROM {{ tmp_relation }}