Skip to content

Commit

Permalink
fix: drop dependent dictionaries before dropping tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Aug 26, 2024
1 parent 4afdbc8 commit 1f64b89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,31 @@


def drop_objects():
# We include these drop statements here because "CREATE OR REPLACE DICTIONARY"
# currently throws a file rename error and you can't drop a dictionary with a
# table referring to it.
op.execute(
f"""
DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.most_recent_course_blocks
DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.course_block_names
{on_cluster}
"""
)

op.execute(
f"""
DROP VIEW IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.most_recent_course_blocks_mv
DROP DICTIONARY IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.course_block_names_dict
{on_cluster}
"""
)

# We include these drop statements here because "CREATE OR REPLACE DICTIONARY"
# currently throws a file rename error and you can't drop a dictionary with a
# table referring to it.
op.execute(
f"""
DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.course_block_names
DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.most_recent_course_blocks
{on_cluster}
"""
)

op.execute(
f"""
DROP DICTIONARY IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.course_block_names_dict
DROP VIEW IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.most_recent_course_blocks_mv
{on_cluster}
"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def drop_objects():
"""
)

op.execute(
f"""
DROP DICTIONARY IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.course_block_names
{on_cluster}
"""
)

op.execute(
f"""
DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.most_recent_course_blocks
Expand Down

0 comments on commit 1f64b89

Please sign in to comment.