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

Fix trino__drop_old_relations and trino__drop_schemas_by_prefixes #2

Merged
merged 1 commit into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions macros/dbt_utils/schema_cleanup/drop_old_relations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
table_schema like '{{ target.schema }}%'
and table_name not in (
{%- for model in current_models -%}
'{{ model.upper() }}'
'{{ model }}'
{%- if not loop.last -%}
,
{% endif %}
Expand All @@ -35,7 +35,6 @@
from
models_to_drop
where
-- intentionally exclude unhandled table_types, including 'external table`
CONCAT( 'drop ' , relation_type , ' ' , relation_name , ';' ) is not null
{% endset %}

Expand Down
6 changes: 3 additions & 3 deletions macros/dbt_utils/schema_cleanup/drop_schemas_by_prefixes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
{# Fetch all schemas that use the current prefix #}
{% do log('Fetching schemas for ' + prefix + '...', info=True) %}
{% set schemas_table %}
select name
from sys.schemas
where name LIKE '{{prefix}}%'
select schema_name
from "{{ target.database }}"."information_schema"."schemata"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What table is schemata ?

Copy link
Contributor Author

@mdesmet mdesmet May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it returns all schema that exist on that catalog (part of information_schema).

where schema_name LIKE '{{prefix}}%'
{% endset %}
{% set schema_names = run_query(schemas_table).columns[0].values() %}

Expand Down