Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
## Fixes
- deduplicate macro for Databricks now uses the QUALIFY clause, which fixes NULL columns issues from the default natural join logic
- deduplicate macro for Redshift now uses the QUALIFY clause, which fixes NULL columns issues from the default natural join logic
- get_tables_by_pattern_sql will now:
- return redshift external tables ([#752](https://github.com/dbt-labs/dbt-utils/issues/752)
- work with valid redshift database names that contain dashes
## Under the hood
- created a new dispatch redshift__get_tables_by_pattern which unions the result of the default macro and querying svv_external_tables for the same conditions (schema name, pattern, exclude pattern).

## Contributors:
[@graciegoheen](https://github.com/graciegoheen)
[@yauhen-sobaleu](https://github.com/yauhen-sobaleu)
[@brendan-cook-87](https://github.com/brendan-cook-87)

# dbt utils v1.1.1
## New features
Expand Down
26 changes: 26 additions & 0 deletions macros/sql/get_tables_by_pattern_sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@

{% endmacro %}

{% macro redshift__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}

{% set sql %}
select distinct
table_schema as {{ adapter.quote('table_schema') }},
table_name as {{ adapter.quote('table_name') }},
{{ dbt_utils.get_table_types_sql() }}
from "{{ database }}"."information_schema"."tables"
where table_schema ilike '{{ schema_pattern }}'
and table_name ilike '{{ table_pattern }}'
and table_name not ilike '{{ exclude }}'
union all
select distinct
schemaname as {{ adapter.quote('table_schema') }},
tablename as {{ adapter.quote('table_name') }},
'external' as {{ adapter.quote('table_type') }}
from svv_external_tables
where redshift_database_name = '{{ database }}'
and schemaname ilike '{{ schema_pattern }}'
and table_name ilike '{{ table_pattern }}'
and table_name not ilike '{{ exclude }}'
{% endset %}

{{ return(sql) }}
{% endmacro %}


{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}

Expand Down