Skip to content

Commit

Permalink
Use fully qualified relations for renames #1031
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 committed May 14, 2024
1 parent 6452e8d commit cea7f05
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dbt/include/snowflake/macros/relations/table/rename.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{%- macro snowflake__get_rename_table_sql(relation, new_name) -%}
alter table {{ relation }} rename to {{ new_name }}
alter table {{ relation }} rename to {{ relation.incorporate(path={"identifier": new_name}) }}

This comment has been minimized.

Copy link
@AartBluestoke

AartBluestoke May 20, 2024

this change would be a breaking change if new_name is already passed in as a relation, rather than as text.
(or at least have a unit test to show that it isn't)

also, what happens if someone has passed in a fully qualified name as a string ? "backup_db.raw.my_tableBackup"

This comment has been minimized.

Copy link
@jtcohen6

jtcohen6 May 20, 2024

Author Contributor

@AartBluestoke To your point, we need to check the type of new_name before assuming it's a string or a Relation.

{%- endmacro -%}
2 changes: 1 addition & 1 deletion dbt/include/snowflake/macros/relations/view/rename.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{%- macro snowflake__get_rename_view_sql(relation, new_name) -%}
alter view {{ relation }} rename to {{ new_name }}
alter view {{ relation }} rename to {{ relation.incorporate(path={"identifier": new_name}) }}
{%- endmacro -%}

0 comments on commit cea7f05

Please sign in to comment.