@@ -468,6 +468,35 @@ handy paired with `union_relations`.
468
468
* ` database ` (optional, default = ` target.database ` ): The database to inspect
469
469
for relations.
470
470
471
+ #### get_relations_by_pattern
472
+ > This was built from the get_relations_by_prefix macro.
473
+
474
+ Returns a list of [ Relations] ( https://docs.getdbt.com/docs/writing-code-in-dbt/class-reference/#relation )
475
+ that match a given schema or table pattern and table/view name with an optional exclusion pattern. Like its cousin
476
+ get_relations_by_prefix, it's particularly handy paired with ` union_relations ` .
477
+ ** Usage:**
478
+ ```
479
+ -- Returns a list of relations that match schema%.table
480
+ {% set relations = dbt_utils.get_relations_by_pattern('schema_pattern%', 'table_pattern') %}
481
+
482
+ -- Returns a list of relations that match schema.table%
483
+ {% set relations = dbt_utils.get_relations_by_pattern('schema_pattern', 'table_pattern%') %}
484
+
485
+ -- Returns a list of relations as above, excluding any that end in `deprecated`
486
+ {% set relations = dbt_utils.get_relations_by_pattern('schema_pattern', 'table_pattern%', '%deprecated') %}
487
+
488
+ -- Example using the union_relations macro
489
+ {% set event_relations = dbt_utils.get_relations_by_pattern('venue%', 'clicks') %}
490
+ {{ dbt_utils.union_relations(relations = event_relations) }}
491
+ ```
492
+
493
+ ** Args:**
494
+ * ` schema_pattern ` (required): The schema pattern to inspect for relations.
495
+ * ` table_pattern ` (required): The name of the table/view (case insensitive).
496
+ * ` exclude ` (optional): Exclude any relations that match this table pattern.
497
+ * ` database ` (optional, default = ` target.database ` ): The database to inspect
498
+ for relations.
499
+
471
500
#### group_by ([ source] ( macros/sql/groupby.sql ) )
472
501
This macro build a group by statement for fields 1...N
473
502
0 commit comments