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: ODS Views and dmap-import sequences #45

Merged
merged 1 commit into from
Feb 4, 2025
Merged

Conversation

rymarczy
Copy link
Contributor

@rymarczy rymarczy commented Feb 4, 2025

This change includes the following:

  • No longer dropping ODS fact tables during spanshot reset, truncate instead (this was causing views to drop)
  • Recreate WC700 Views dropped during snapshot reset.
  • Create ad_hoc_processed_taps View with associated index.

Comment on lines +25 to +34
pass
# Delete status files for all tables loaded since the NOT NULL Primary Key requirement was dropped.
# This will force a reset/re-load for these tables in dmap-import DB
s3_delete_object(os.path.join(ODS_STATUS, "EDW.PAYMENT_SUMMARY.json"))
s3_delete_object(os.path.join(ODS_STATUS, "EDW.MEMBER_DIMENSION.json"))
op.drop_table("edw_payment_summary", schema="ods")
op.drop_table("edw_payment_summary_history", schema="ods")
op.drop_table("edw_member_dimension", schema="ods")
op.drop_table("edw_member_dimension_history", schema="ods")
# This was one-time migration, does not need to remain active
# s3_delete_object(os.path.join(ODS_STATUS, "EDW.PAYMENT_SUMMARY.json"))
# s3_delete_object(os.path.join(ODS_STATUS, "EDW.MEMBER_DIMENSION.json"))
# op.drop_table("edw_payment_summary", schema="ods")
# op.drop_table("edw_payment_summary_history", schema="ods")
# op.drop_table("edw_member_dimension", schema="ods")
# op.drop_table("edw_member_dimension_history", schema="ods")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was causing issues during local testing, should never need to be run again.

@@ -445,7 +445,7 @@ def snapshot_reset(self) -> None:
self.etl_status = self.load_etl_status()

self.db.execute(drop_table(self.db_history_table))
self.db.execute(drop_table(self.db_fact_table))
self.db.truncate_table(self.db_fact_table, restart_identity=True, cascade=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drop command was causing VIEWS to get dropped...

@@ -0,0 +1,134 @@
AD_HOC_VIEW = """
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keep these VIEW statements in central location.

@rymarczy rymarczy requested a review from grejdi-mbta February 4, 2025 16:49
op.drop_table("edw_member_dimension", schema="ods")
op.drop_table("edw_member_dimension_history", schema="ods")
# This was one-time migration, does not need to remain active
# s3_delete_object(os.path.join(ODS_STATUS, "EDW.PAYMENT_SUMMARY.json"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I gotta tell you. This concept of using migrations to do other migration-related things blew my mind. 😂

@rymarczy rymarczy merged commit 50c2d98 into main Feb 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants