Sync lookup tables on a daily schedule

Recipe ToolsMarketing

What it does

When a scheduled time arrives each day, this automation clears the town_state_merge lookup table and rebuilds it. Entries from rank_town and rank_state lookup tables are retrieved and merged so downstream processes have current reference data.

Who it's for

Data and analytics teams who maintain lookup tables that need to refresh on a fixed schedule.

How teams use this

Refresh merged reference data daily

Run the lookup table merge every morning so downstream queries always have current town and state combinations. The schedule keeps data fresh without manual intervention.

Support reporting on geographic data

Use the merged lookup table in reports and dashboards that need to cross-reference towns with their states. The daily refresh ensures reports reflect the latest reference data.

Add a validation step before merge

Include a condition to check that rank_state entries exist before adding them to town_state_merge, so only valid combinations are stored. This prevents incomplete records in the merged table.

How it works

  1. Start the daily refresh. At 12:00 AM each day, the Clock triggers this automation to begin the lookup table refresh cycle.
  2. Clear the merge table. Truncate all entries from the town_state_merge lookup table in the Lookup Table to remove stale data before the rebuild.
  3. Retrieve town and state entries. Fetch all entries from rank_town and rank_state lookup tables in batch mode using the Lookup Table to prepare for the merge.
  4. Match and merge each entry. For each town entry, search the rank_state lookup table for matching state data, then add the combined record to town_state_merge.