Skip to content
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
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Tox will take care of installing the dependencies for each environment, so you d
tox -e integration_snowflake # For the Snowflake tests
tox -e integration_databricks # For the Databricks tests
tox -e integration_bigquery # For the BigQuery tests
tox -e integration_redshift # For the Redshift tests
```

The Spark tests require installing the [ODBC driver](https://www.databricks.com/spark/odbc-drivers-download). On a Mac,
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The package currently supports
- Postgres :white_check_mark:
- SQL Server :white_check_mark:
- Trino :white_check_mark:
- Redshift :white_check_mark:

Models included:

Expand Down
5 changes: 5 additions & 0 deletions integration_test_project/example-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export DBT_ENV_SECRET_DATABRICKS_TOKEN=
export DBT_ENV_SECRET_GCP_PROJECT=
export DBT_ENV_SPARK_DRIVER_PATH= # /Library/simba/spark/lib/libsparkodbc_sbu.dylib on a Mac
export DBT_ENV_SPARK_ENDPOINT= # The endpoint ID from the Databricks HTTP path
export DBT_ENV__REDSHIFT__HOST=
export DBT_ENV__REDSHIFT__DBNAME=
export DBT_ENV__REDSHIFT__SCHEMA=
export DBT_ENV__REDSHIFT__USER=
export DBT_ENV__REDSHIFT__PASSWORD=

# dbt environment variables, change these
export DBT_VERSION="1_5_0"
Expand Down
12 changes: 12 additions & 0 deletions integration_test_project/profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,15 @@ dbt_artifacts:
schema: default
port: 8080
threads: 8
redshift:
type: redshift
host: "{{ env_var('DBT_ENV__REDSHIFT__HOST') }}"
port: "{{ env_var('DBT_ENV__REDSHIFT__PORT', 5439) | int }}"
dbname: "{{ env_var('DBT_ENV__REDSHIFT__DBNAME', 'main') }}"
schema: "{{ env_var('DBT_ENV__REDSHIFT__SCHEMA', 'public') }}"
connect_timeout: "{{ env_var('DBT_ENV__REDSHIFT__CONNECT_TIMEOUT', 100) | int }}"
sslmode: "{{ env_var('DBT_ENV__REDSHIFT__SSL_MODE', 'prefer') }}"
ra3_node: "{{ env_var('DBT_ENV__REDSHIFT__RA3_NODE', False) | as_bool }}"
threads: "{{ env_var('DBT_ENV__REDSHIFT__THREADS', 8) | int }}"
user: "{{ env_var('DBT_ENV__REDSHIFT__USER') }}"
password: "{{ env_var('DBT_ENV__REDSHIFT__PASSWORD') }}"
8 changes: 8 additions & 0 deletions macros/database_specific_helpers/parse_json.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@
safe.parse_json("""{{ field }}""", wide_number_mode=>'round')
{%- endmacro %}

{% macro redshift__parse_json(field) %}
case
when can_json_parse({{ field }})
then json_parse({{ field }})
else
{{ field }}
end
{%- endmacro %}
22 changes: 21 additions & 1 deletion macros/database_specific_helpers/type_helpers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
json
{% endmacro %}

{% macro redshift__type_json() %}
varchar(max)
{% endmacro %}

{#- ARRAY -#}

{% macro type_array() %}
Expand All @@ -48,7 +52,11 @@
array(varchar)
{% endmacro %}

{#- NUMERIC -#}%}
{% macro redshift__type_array() %}
varchar(max)
{% endmacro %}

{#- NUMERIC -#}

{% macro type_numeric() %}
{{ return(adapter.dispatch('type_numeric', 'dbt_artifacts')()) }}
Expand All @@ -61,3 +69,15 @@
{% macro trino__type_numeric() %}
double
{% endmacro %}

{% macro type_string() %}
{{ return(adapter.dispatch('type_string', 'dbt_artifacts')()) }}
{% endmacro %}

{% macro default__type_string() %}
{{ return(api.Column.translate_type("string")) }}
{% endmacro %}

{% macro redshift__type_string() %}
varchar(max)
{% endmacro %}
12 changes: 8 additions & 4 deletions macros/integration_tests/safe_cast.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,35 @@
'bigquery': 'STRING',
'snowflake': 'VARCHAR',
'databricks': 'STRING',
'trino': 'VARCHAR'
'trino': 'VARCHAR',
'redshift': 'TEXT'
},
'integer': {
'postgres': 'NUMERIC',
'sqlserver': 'FLOAT',
'bigquery': 'FLOAT64',
'snowflake': 'FLOAT',
'databricks': 'DOUBLE',
'trino': 'DOUBLE'
'trino': 'DOUBLE',
'redshift': 'NUMERIC'
},
'date': {
'postgres': 'DATE',
'sqlserver': 'DATE',
'bigquery': 'DATE',
'snowflake': 'DATE',
'databricks': 'DATE',
'trino': 'DATE'
'trino': 'DATE',
'redshift': 'DATE'
},
'timestamp': {
'postgres': 'TIMESTAMP',
'sqlserver': 'DATETIME2',
'bigquery': 'TIMESTAMP',
'snowflake': 'TIMESTAMP',
'databricks': 'TIMESTAMP',
'trino': 'TIMESTAMP'
'trino': 'TIMESTAMP',
'redshift': 'TIMESTAMPTZ'
}
} %}

Expand Down