app_installs
was replaced by app_installs_v2
.
This tutorial will walk through the deprecation of app_installs
and demonstrate
how SDF can help overcome the two big hurdles in deprecating a model:
workspace.sdf.yml
.
Open the file workspace.sdf.yml
and uncomment the following:
Before Deprecation
Table: moms_flower_shop.staging.app_installsmoms_flower_shop.staging.app_installs.campaign_idmoms_flower_shop.staging.app_installs.campaign_name
│
│ copy
└──────┐
moms_flower_shop.analytics.agg_installs_and_campaigns.campaign_namemoms_flower_shop.staging.app_installs.campaign_typemoms_flower_shop.staging.app_installs.customer_id
│
│ mod
└──────┐
moms_flower_shop.analytics.agg_installs_and_campaigns.distinct_installsmoms_flower_shop.staging.app_installs.event_idmoms_flower_shop.staging.app_installs.install_time
│
│ mod
└──────┐
moms_flower_shop.analytics.agg_installs_and_campaigns.install_datemoms_flower_shop.staging.app_installs.platform
│
│ copy
└──────┐
moms_flower_shop.analytics.agg_installs_and_campaigns.platform
agg_installs_and_campaigns
is also using the
old version table!Classify the Model as Deprecated
classifications/table_classifiers.sdf.yml
holds definitions of
a table level classifier called TABLE_STATUS
. You can see that one of the
table status options is deprecated
.To add the classifier to our table, navigate to the table’s metadata file
metadata/staging/app_installs.sdf.yml
. Remove the commented
section assigning the TABLE_STATUS.deprecated
classifier to the table:Schema moms_flower_shop.staging.app_installs
This table is a staging table which adds campaign information to app install events
[TABLE_STATUS.deprecated]
┌───────────────┬───────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ column_name ┆ data_type ┆ classifier ┆ description │
╞═══════════════╪═══════════╪════════════╪══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╡
│ event_id ┆ bigint ┆ ┆ │
│ customer_id ┆ bigint ┆ ┆ The identifier of the customer that performed the event │
│ install_time ┆ timestamp ┆ ┆ │
│ platform ┆ varchar ┆ ┆ iOS or Android │
│ campaign_id ┆ bigint ┆ ┆ The identifier of the campaign that is associated with the event │
│ campaign_name ┆ varchar ┆ ┆ The campaign name associated with the campaign_id │
│ campaign_type ┆ varchar ┆ ┆ A substring of the campaign name contain the campaign type. Supported types - instagram_ads, friends_referrals, facebook_ads, google_search │
│ ┆ ┆ ┆ │
└───────────────┴───────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Create a Report of References to Deprecated Tables
deprecated_table_reference.sql
in the
reports/
directory. Copy the following query to your new file:agg_installs_and_campaigns
is referencing the old table. It’s a good test to check -
we expect it to fail.Let’s check it out (pun intended):Report moms_flower_shop.pub.deprecated_table_reference
┌───────────────────────────────────────────────────────┬───────────────────────────────────────┐
│ table_id ┆ upstream_deprecated_table_id │
╞═══════════════════════════════════════════════════════╪═══════════════════════════════════════╡
│ moms_flower_shop.analytics.agg_installs_and_campaigns ┆ moms_flower_shop.staging.app_installs │
└───────────────────────────────────────────────────────┴───────────────────────────────────────┘
1 rows.
agg_installs_and_campaigns
.Resolve Downstream Dependencies
FROM
statement of models/analytics/agg_installs_and_campaigns.sql
like we did for our previous model:Report moms_flower_shop.pub.deprecated_table_reference
┌──────────┬──────────────────────────────┐
│ table_id ┆ upstream_deprecated_table_id │
╞══════════╪══════════════════════════════╡
└──────────┴──────────────────────────────┘
0 rows.