Skip to content

Commit

Permalink
Merge pull request #42 from dbt-labs/use-get-relations-by-pattern
Browse files Browse the repository at this point in the history
Use get relations by pattern
  • Loading branch information
jtcohen6 authored Jul 7, 2021
2 parents ff1fecf + f653f36 commit ed95cbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dbt-codegen v0.4.0 (unreleased)

## Fixes
- In the `generate_source` macro, use `dbt_utils.get_relations_by_pattern` instead of `get_relations_by_prefix`, since the latter will be deprecated in the future (#42)

## Features
- Add optional leading_commas arg to generate_base_model (#41 @jaypeedevlin)
Expand Down
17 changes: 7 additions & 10 deletions macros/generate_source.sql
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{% macro get_tables_in_schema(schema_name,database_name=target.database) %}
{% macro get_tables_in_schema(schema_name, database_name=target.database) %}

{% set tables=dbt_utils.get_relations_by_prefix(
schema=schema_name,
prefix='',
database=database_name
)
%}
{% set tables=dbt_utils.get_relations_by_pattern(
database=database_name,
schema_pattern=schema_name,
table_pattern='%'
) %}

{% set table_list= tables | map(attribute = 'identifier') %}
{% set table_list= tables | map(attribute='identifier') %}

{{ return(table_list | sort) }}
{{ log("*** table list ***", info=True) }}
{{ log(table_list, info=True) }}

{% endmacro %}

Expand Down

0 comments on commit ed95cbf

Please sign in to comment.