-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement relation filtering on get_catalog macro (#1073)
* changelog * turn on get_catalog by relations * add get_catalog_relations, break apart get_catalog for reuse in get_catalog_relations --------- Co-authored-by: colin-rogers-dbt <[email protected]>
- Loading branch information
1 parent
24748d2
commit 74f6ba5
Showing
6 changed files
with
254 additions
and
236 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Support limiting get_catalog by object name | ||
time: 2023-12-19T20:12:03.990725-05:00 | ||
custom: | ||
Author: mikealfare | ||
Issue: "950" |
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 was deleted.
Oops, something went wrong.
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,36 @@ | ||
{% macro bigquery__get_catalog_relations(information_schema, relations) -%} | ||
|
||
{%- if (relations | length) == 0 -%} | ||
{# Hopefully nothing cares about the columns we return when there are no rows #} | ||
{%- set query = "select 1 as id limit 0" -%} | ||
|
||
{%- else -%} | ||
{%- set query -%} | ||
with | ||
table_shards_stage as ({{ _bigquery__get_table_shards_sql(information_schema) }}), | ||
table_shards as ( | ||
select * from table_shards_stage | ||
where ( | ||
{%- for relation in relations -%} | ||
( | ||
upper(table_schema) = upper('{{ relation.schema }}') | ||
and upper(table_name) = upper('{{ relation.identifier }}') | ||
) | ||
{%- if not loop.last %} or {% endif -%} | ||
{%- endfor -%} | ||
) | ||
), | ||
tables as ({{ _bigquery__get_tables_sql() }}), | ||
table_stats as ({{ _bigquery__get_table_stats_sql() }}), | ||
|
||
columns as ({{ _bigquery__get_columns_sql(information_schema) }}), | ||
column_stats as ({{ _bigquery__get_column_stats_sql() }}) | ||
|
||
{{ _bigquery__get_extended_catalog_sql() }} | ||
{%- endset -%} | ||
|
||
{%- endif -%} | ||
|
||
{{ return(run_query(query)) }} | ||
|
||
{%- 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,32 @@ | ||
{% macro bigquery__get_catalog(information_schema, schemas) -%} | ||
|
||
{%- if (schemas | length) == 0 -%} | ||
{# Hopefully nothing cares about the columns we return when there are no rows #} | ||
{%- set query = "select 1 as id limit 0" -%} | ||
|
||
{%- else -%} | ||
{%- set query -%} | ||
with | ||
table_shards as ( | ||
{{ _bigquery__get_table_shards_sql(information_schema) }} | ||
where ( | ||
{%- for schema in schemas -%} | ||
upper(tables.dataset_id) = upper('{{ schema }}') | ||
{%- if not loop.last %} or {% endif -%} | ||
{%- endfor -%} | ||
) | ||
), | ||
tables as ({{ _bigquery__get_tables_sql() }}), | ||
table_stats as ({{ _bigquery__get_table_stats_sql() }}), | ||
|
||
columns as ({{ _bigquery__get_columns_sql(information_schema) }}), | ||
column_stats as ({{ _bigquery__get_column_stats_sql() }}) | ||
|
||
{{ _bigquery__get_extended_catalog_sql() }} | ||
{%- endset -%} | ||
|
||
{%- endif -%} | ||
|
||
{{ return(run_query(query)) }} | ||
|
||
{%- endmacro %} |
Oops, something went wrong.