|
| 1 | +# Bruin - Bronze to Silver BigQuery Template |
| 2 | + |
| 3 | +This template demonstrates a complete bronze-to-silver pattern built on top of |
| 4 | +BigQuery. It combines a raw ingestion step powered by ingestr with a curated |
| 5 | +transformation layer that adds analytics-friendly aggregates and data quality |
| 6 | +checks. |
| 7 | + |
| 8 | +## Pipeline Overview |
| 9 | + |
| 10 | +- `assets/bronze_raw_data.asset.yml` creates the **bronze** layer by loading |
| 11 | + publicly available foreign exchange rates from the Frankfurter API into |
| 12 | + BigQuery. |
| 13 | +- `assets/silver_aggregated.sql` materializes the **silver** layer by computing |
| 14 | + rolling 7-day averages and day-over-day deltas for each currency. |
| 15 | +- `pipeline.yml` wires the assets together and defines default connections for |
| 16 | + Frankfurter and Google Cloud. |
| 17 | +- `.bruin.yml` contains a starter configuration you can adapt with your own |
| 18 | + GCP project and service account. |
| 19 | + |
| 20 | +## Initialize the Template |
| 21 | + |
| 22 | +```bash |
| 23 | +bruin init bronze-silver-bigquery |
| 24 | +``` |
| 25 | + |
| 26 | +This creates a folder with the files listed above so you can run the template in |
| 27 | +place or tailor it to your environment. |
| 28 | + |
| 29 | +## Configure Connections |
| 30 | + |
| 31 | +Update `.bruin.yml` with your Google Cloud project details and service account. |
| 32 | +The Frankfurter source does not require credentials, but you can rename the |
| 33 | +connection if desired. |
| 34 | + |
| 35 | +```yaml |
| 36 | +default_environment: default |
| 37 | +environments: |
| 38 | + default: |
| 39 | + connections: |
| 40 | + frankfurter: |
| 41 | + - name: "frankfurter-default" |
| 42 | + google_cloud_platform: |
| 43 | + - name: "gcp-default" |
| 44 | + project_id: "your-gcp-project-id" |
| 45 | + service_account_file: "/path/to/service-account.json" |
| 46 | +``` |
| 47 | +
|
| 48 | +> **BigQuery dataset**: The template writes to the `bronze` and `silver` |
| 49 | +> datasets. Create them ahead of time or change the dataset names in the asset |
| 50 | +> definitions to match your environment. |
| 51 | + |
| 52 | +## Run the Pipeline |
| 53 | + |
| 54 | +Validate and execute the pipeline from the template directory: |
| 55 | + |
| 56 | +```bash |
| 57 | +bruin validate . |
| 58 | +bruin run . |
| 59 | +``` |
| 60 | + |
| 61 | +The bronze asset loads historical exchange rates, and the silver asset enriches |
| 62 | +that data with rolling metrics suitable for downstream analytics and reporting. |
| 63 | + |
| 64 | +## Data Quality Highlights |
| 65 | + |
| 66 | +- Every column in the bronze asset is monitored for nulls, and a custom check |
| 67 | + ensures the base currency remains `EUR`. |
| 68 | +- The silver layer adds positive and not-null checks, plus a custom validation |
| 69 | + that guarantees rolling averages are present for data older than seven days. |
| 70 | + |
| 71 | +## Next Steps |
| 72 | + |
| 73 | +- Swap in another no-auth source such as the Chess template by updating the |
| 74 | + `source_connection` and transformation logic. |
| 75 | +- Extend the silver layer with additional materializations (e.g. gold-level |
| 76 | + dashboards or alerts). |
| 77 | +- Schedule the pipeline using the `schedule` and `start_date` fields in |
| 78 | + `pipeline.yml` or integrate it with your orchestrator of choice. |
0 commit comments