Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADAP-865: Parameterize where clause, add option to supply list of relations #758

Merged
merged 21 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
546f132
parameterize where clause, add option to supply list of relations
mikealfare Aug 29, 2023
ac21429
parameterize where clause, add option to supply list of relations
mikealfare Aug 29, 2023
b1a2f7d
revert whitespace fix
mikealfare Aug 29, 2023
cad0555
revert whitespace fix
mikealfare Aug 29, 2023
9fb0839
revert whitespace fix
mikealfare Aug 29, 2023
6e4e0b2
fix missing macro keyword
mikealfare Aug 29, 2023
673e1c5
point to the dev branch on core, revert before pushing to main
mikealfare Sep 13, 2023
9db81be
Merge branch 'main' into feature/applied-state/get-catalog-by-object
mikealfare Sep 14, 2023
9bdacf9
add new macro get_catalog_relations, update get_catalog to share comm…
mikealfare Sep 15, 2023
e624ff1
fixed reference in get_catalog_relations, added original dict version…
mikealfare Sep 15, 2023
de33932
remove dict version of relations based get_catalog, point to List[Bas…
mikealfare Sep 19, 2023
c72be56
Merge branch 'main' into feature/applied-state/get-catalog-by-object
mikealfare Sep 26, 2023
6ed39f0
Merge branch 'main' into feature/applied-state/get-catalog-by-object
mikealfare Oct 3, 2023
26db949
point dev reqs back to main on core
mikealfare Oct 3, 2023
3b7dbff
fix typo in schemas argument
mikealfare Oct 4, 2023
08212d2
add feature flag to turn on relation filtering for get_catalog
mikealfare Oct 4, 2023
d908ff8
update changelog to point to the PR instead of a broken url
mikealfare Oct 9, 2023
7d5f735
Merge branch 'main' into feature/applied-state/get-catalog-by-object
mikealfare Oct 11, 2023
290cb77
Merge branch 'main' into feature/applied-state/get-catalog-by-object
mikealfare Oct 11, 2023
e591600
Merge branch 'main' into feature/applied-state/get-catalog-by-object
mikealfare Oct 11, 2023
423535e
Support changes to dbt-core capability system
peterallenwebb Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230829-152412.yaml
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-08-29T15:24:12.649104-04:00
custom:
Author: mikealfare
Issue: "4997"
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
47 changes: 36 additions & 11 deletions dbt/include/snowflake/macros/catalog.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro snowflake__get_catalog(information_schema, schemas) -%}
{% macro snowflake__get_catalog(information_schema, schemas, relations) -%}
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
{% set query %}
with tables as (

Expand Down Expand Up @@ -33,11 +33,7 @@
(last_altered is not null and table_type='BASE TABLE') as "stats:last_modified:include"

from {{ information_schema }}.tables
where (
{%- for schema in schemas -%}
upper("table_schema") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}
{%- endfor -%}
)
{{ snowflake__get_catalog_where_clause(schemas, relations) }}

),

Expand All @@ -54,11 +50,7 @@
comment as "column_comment"

from {{ information_schema }}.columns
where (
{%- for schema in schemas -%}
upper("table_schema") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}
{%- endfor -%}
)
{{ snowflake__get_catalog_where_clause(schemas, relations) }}
)

select *
Expand All @@ -70,3 +62,36 @@
{{ return(run_query(query)) }}

{%- endmacro %}


{% snowflake__get_catalog_where_clause(schemas, relations) %}

{% if schemas is not none %}
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
where (
{%- for schema in schemas -%}
upper("table_schema") = upper('{{ schema }}')
{%- if not loop.last %} or {% endif -%}
{%- endfor -%}
)

{% elif relations is not none %}
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
where (
{%- for relation in relations -%}
(
upper("table_schema") = upper('{{ relation.schema }}')
{% if relation.identifier is not none %}
and upper("table_name") = upper('{{ relation.identifier }}')
{% endif %}
)
{%- if not loop.last %} or {% endif -%}
{%- endfor -%}
)

{% else %}
{% do exceptions.raise_compiler_error(
'`get_catalog` requires a list of schemas or a list of relations.'
) %}

{% endif %}

{% endmacro %}