Reapit

Orchestration

← Back to Projects

Bronze — Daily Incremental Load

  1. Pipeline load_bronze runs the update_watermark Script activity. It sets CONFIG.Processes.WatermarkValue = MAX(SYNCHDATE) per table from Reapit_Bronze_DWH.ODS.synchdates. This is the value the next run will filter on. Currently deactivated (state: Inactive) — the watermark is not being refreshed automatically.
  2. get_bronze_tables Script activity reads SELECT * FROM CONFIG.Processes WHERE IngnoreInBronzeETL = 0.
  3. for_each_bronze_table ForEach iterates the returned rows sequentially.
  4. For each row, the source SELECT is built dynamically. The date used in the WHERE clause is CONFIG.Processes.WatermarkValue for that row — unless it is empty or earlier than the pipeline variable v_MinWatermarkValue (2023-09-20 17:03:14), in which case that floor is used instead.
  5. Query filter:
    • isIncremental = 1WHERE {WatermarkField} > '{date from step 4}' AND SynchDel = 0
    • isIncremental = 0WHERE SynchDel = 0
    • TableName = 'CONFIGSETTING' → no SynchDel filter (column does not exist)
  6. land_bronze Copy activity runs the query against Snowflake and writes to Lakehouse {TargetSchemaName}.{TableName}.
  7. Sink action is OverwriteSchema. The Bronze table is dropped and recreated on every run — it holds only the rows returned by this iteration's query, not accumulated history. Persistent history lives downstream in Silver / ODS.
  8. Loop advances to the next row; on completion the pipeline ends. Step 1's watermark refresh will run at the start of the next scheduled execution (once reactivated).

Silver — Load ODS

  1. Pipeline load_ods runs the get_notebooks_to_run Script activity: SELECT * FROM CONFIG.Processes WHERE IngnoreInSilverETL = 0.
  2. for_each_notebook ForEach iterates the returned rows sequentially.
  3. For each row, a TridentNotebook activity invokes the dispatcher notebook 00_run_notebook, passing NotebookName = item().SilverNotebookName. Activity timeout: 12 hours.
  4. 00_run_notebook calls notebookutils.notebook.run(NotebookName, 10800) — 180 minute timeout per notebook.
  5. The target merge notebook (e.g. 01_merge_lookup, 03_merge_cnt) runs against the Reapit_Silver_LH lakehouse. It reads the current Bronze landing tables (LANDING.* or LANDING_PP.*) using spark.table(...), projects and reshapes the columns, and combines active / archive sources where relevant.
  6. The notebook then performs a Delta MERGE into the corresponding ODS.{table}: whenMatchedUpdate refreshes columns and sets LASTUPDATED = current_timestamp(); whenNotMatchedInsert adds new rows. ODS tables are the persistent history — unlike Bronze, they are upserted, not overwritten.
  7. After the merge, the notebook computes MAX(_FIVETRAN_SYNCED) per source landing table and MERGEs those values into ODS.SYNCHDATES (columns REAPITTABLE, SYNCHDATE). This is the table Bronze's update_watermark reads at the start of the next daily run.
  8. If the merge or synchdate update raises an exception, the notebook re-raises — the ForEach iteration fails and the pipeline moves on to the next row (no stopOnFailure). ODS.SYNCHDATES is only updated when the corresponding merge succeeds, so a failing table cannot advance its own watermark.
  9. Loop advances to the next row; on completion the pipeline ends.

Gold

To be documented.

End-to-end sync review

Data sync coverage
Bronze → Silver → Bronze feedback loop
SQL Endpoint / Lakehouse refresh risks
Recommended actions (in order)
  1. Fix deletes: either widen Bronze filter to include soft-deleted rows and teach Silver MERGE to whenMatchedDelete on SynchDel = 1 / _FIVETRAN_DELETED = true, or complete notebook 09 Update Deleted Records as a separate diff sweep.
  2. Verify LANDING and ODS shortcuts exist in Reapit_Silver_LH before reactivating update_watermark.
  3. Reactivate update_watermark in load_bronze.
  4. Handle CONFIGSETTING deletes with a full-diff notebook (no SynchDel to filter on, so needs a set-difference against source).
  5. Add a pre-flight guardrail: fail load_ods if get_notebooks_to_run returns a row whose SilverNotebookName does not exist as a notebook in the workspace.