-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix quoting on columns for seeds/incremental models
Added tests
- Loading branch information
Jacob Beck
committed
Nov 4, 2019
1 parent
670c26b
commit ffcf7af
Showing
6 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"col_A","col_B" | ||
1,2 | ||
3,4 | ||
5,6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% set col_a = '"col_A"' %} | ||
{% set col_b = '"col_B"' %} | ||
{% if adapter.type() == 'bigquery' %} | ||
{% set col_a = '`col_A`' %} | ||
{% set col_b = '`col_B`' %} | ||
{% endif %} | ||
|
||
{{config( | ||
materialized = 'incremental', | ||
unique_key = col_a, | ||
incremental_strategy = "delete+insert" | ||
)}} | ||
|
||
select | ||
{{ col_a }}, {{ col_b }} | ||
from {{ref('seed')}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from test.integration.base import DBTIntegrationTest, use_profile | ||
import os | ||
|
||
|
||
class TestColumnQuoting(DBTIntegrationTest): | ||
@property | ||
def schema(self): | ||
return 'dbt_column_quoting_052' | ||
|
||
@staticmethod | ||
def dir(value): | ||
return os.path.normpath(value) | ||
|
||
@property | ||
def models(self): | ||
return self.dir('models') | ||
|
||
def _run_columnn_quotes(self): | ||
self.run_dbt(['seed']) | ||
self.run_dbt() | ||
self.run_dbt() | ||
|
||
@use_profile('postgres') | ||
def test_postgres_column_quotes(self): | ||
self._run_columnn_quotes() | ||
|
||
@use_profile('redshift') | ||
def test_redshift_column_quotes(self): | ||
self._run_columnn_quotes() | ||
|
||
@use_profile('snowflake') | ||
def test_snowflake_column_quotes(self): | ||
self._run_columnn_quotes() | ||
|
||
@use_profile('bigquery') | ||
def test_bigquery_column_quotes(self): | ||
self._run_columnn_quotes() |