-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from fivetran/explore/drop-integration-test-s…
…chemas exploring integration test schema cleanup
- Loading branch information
Showing
6 changed files
with
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: 'fivetran_utils' | ||
version: '0.4.3' | ||
version: '0.4.4' | ||
config-version: 2 | ||
require-dbt-version: [">=1.3.0", "<2.0.0"] |
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,31 @@ | ||
{% macro drop_schemas_automation(drop_target_schema=true) %} | ||
{{ return(adapter.dispatch('drop_schemas_automation', 'fivetran_utils')(drop_target_schema)) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__drop_schemas_automation(drop_target_schema=true) %} | ||
|
||
{% set fetch_list_sql %} | ||
{% if target.type not in ('databricks', 'spark') %} | ||
select schema_name | ||
from | ||
{{ wrap_in_quotes(target.database) }}.INFORMATION_SCHEMA.SCHEMATA | ||
where lower(schema_name) like '{{ target.schema | lower }}{%- if not drop_target_schema -%}_{%- endif -%}%' | ||
{% else %} | ||
SHOW SCHEMAS LIKE '{{ target.schema }}{%- if not drop_target_schema -%}_{%- endif -%}*' | ||
{% endif %} | ||
{% endset %} | ||
|
||
{% set results = run_query(fetch_list_sql) %} | ||
|
||
{% if execute %} | ||
{% set results_list = results.columns[0].values() %} | ||
{% else %} | ||
{% set results_list = [] %} | ||
{% endif %} | ||
|
||
{% for schema_to_drop in results_list %} | ||
{% do adapter.drop_schema(api.Relation.create(database=target.database, schema=schema_to_drop)) %} | ||
{{ print('Schema ' ~ schema_to_drop ~ ' successfully dropped from the ' ~ target.database ~ ' database.\n')}} | ||
{% endfor %} | ||
|
||
{% endmacro %} |
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,22 @@ | ||
{%- macro wrap_in_quotes(object_to_quote) -%} | ||
|
||
{{ return(adapter.dispatch('wrap_in_quotes', 'fivetran_utils')(object_to_quote)) }} | ||
|
||
{%- endmacro -%} | ||
|
||
{%- macro default__wrap_in_quotes(object_to_quote) -%} | ||
{# bigquery, spark, databricks #} | ||
`{{ object_to_quote }}` | ||
{%- endmacro -%} | ||
|
||
{%- macro snowflake__wrap_in_quotes(object_to_quote) -%} | ||
"{{ object_to_quote | upper }}" | ||
{%- endmacro -%} | ||
|
||
{%- macro redshift__wrap_in_quotes(object_to_quote) -%} | ||
"{{ object_to_quote }}" | ||
{%- endmacro -%} | ||
|
||
{%- macro postgres__wrap_in_quotes(object_to_quote) -%} | ||
"{{ object_to_quote }}" | ||
{%- endmacro -%} |