-
Notifications
You must be signed in to change notification settings - Fork 161
/
by_schema.sql
32 lines (25 loc) · 1.14 KB
/
by_schema.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 %}