Skip to content

Commit

Permalink
Typed materialized views as views (#525)
Browse files Browse the repository at this point in the history
* Typed materialized views as views

* Update get_relations_by_pattern.sql

* Moving fix from get_tables_by_pattern_sql

reverting changes to this file to add a fix to the macro get_tables_by_pattern_sql

* removing quoting from table_type

removing quoting from table_type as this was causing an error when calling this macro within get_tables_by_pattern_sql

* calling get_table_types_sql for materialized views

calling get_table_types_sql macro to handle materialized views in sources.
  • Loading branch information
luisleon90 authored Mar 23, 2022
1 parent 3a4cc94 commit e2f6ba7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# dbt-utils v0.8.3
## New features
- A macro for deduplicating data ([#335](https://github.com/dbt-labs/dbt-utils/issues/335), [#512](https://github.com/dbt-labs/dbt-utils/pull/512))
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ models:
<summary>Additional `gaps` and `zero_length_range_allowed` examples</summary>

**Understanding the `gaps` argument:**

Here are a number of examples for each allowed `gaps` argument.
* `gaps: not_allowed`: The upper bound of one record must be the lower bound of
the next record.
Expand Down Expand Up @@ -787,7 +786,7 @@ from {{ ref('my_model') }}
This macro unions together an array of [Relations](https://docs.getdbt.com/docs/writing-code-in-dbt/class-reference/#relation),
even when columns have differing orders in each Relation, and/or some columns are
missing from some relations. Any columns exclusive to a subset of these
relations will be filled with `null` where not present. An new column
relations will be filled with `null` where not present. A new column
(`_dbt_source_relation`) is also added to indicate the source for each record.

**Usage:**
Expand Down
2 changes: 1 addition & 1 deletion macros/sql/get_relations_by_pattern.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
database=database,
schema=row.table_schema,
identifier=row.table_name,
type=row.table_type
type = row.table_type
) -%}
{%- do tbl_relations.append(tbl_relation) -%}
{%- endfor -%}
Expand Down
2 changes: 1 addition & 1 deletion macros/sql/get_table_types_sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
when 'EXTERNAL TABLE' then 'external'
when 'MATERIALIZED VIEW' then 'materializedview'
else lower(table_type)
end as "table_type"
end as table_type
{% endmacro %}


Expand Down
5 changes: 1 addition & 4 deletions macros/sql/get_tables_by_pattern_sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
select distinct
table_schema,
table_name,
case table_type
when 'BASE TABLE' then 'table'
else lower(table_type)
end as table_type
{{ dbt_utils.get_table_types_sql() }}

from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES
where lower(table_name) like lower ('{{ table_pattern }}')
Expand Down

0 comments on commit e2f6ba7

Please sign in to comment.