Back to Blog
    dbtanalytics-engineeringtransformationdata-modelingsql

    Analytics Engineering with dbt: From ETL to ELT

    Aivena Engineering2026-02-112 min read

    Analytics Engineering with dbt: From ETL to ELT

    The modern standard for data transformation is dbt (data build tool). dbt allows analysts and engineers to transform data in their warehouse (ClickHouse, Postgres, Snowflake) by writing SQL SELECT statements. dbt handles the boilerplate of turning these into tables and views.

    The dbt Software Development Lifecycle (SDLC)

    When you treat data like software, your workflow looks like this:

    graph LR subgraph Dev [Development] IDE[VSCode Cloud] -->|Write SQL| LocalRun[dbt run/test] end subgraph CI [Continuous Integration] PR[Pull Request] -->|Trigger| SlimCI[Slim CI Run] SlimCI -->|Test| Schema[Schema Validation] SlimCI -->|Test| DataQuality[Data Quality Gates] end subgraph Prod [Production] Airflow[Airflow Scheduler] -->|Trigger| DbtProd[dbt run -s state:modified] DbtProd -->|Update| GoldTables[Gold Tables] end Dev --> PR PR -->|Merge| Prod style Dev fill:#f5f7ff,stroke:#4a6cf7 style CI fill:#fff9f0,stroke:#f59e0b style Prod fill:#f0fff4,stroke:#22c55e

    1. Power Up with Macros and Custom Tests

    dbt's true power lies in its Jinja templating. Instead of repeating complex logic, you write Macros.

    Example: Custom Currency Converter Macro

    sql

    -- macros/convert_currency.sql

    {% macro convert_to_usd(column_name, currency_code_column) %}

    ({{ column_name }} * (

    case

    when {{ currency_code_column }} = 'EUR' then 1.08

    when {{ currency_code_column }} = 'GBP' then 1.27

    else 1.0

    end

    ))

    {% endmacro %}

    Usage in a Model

    sql

    select 

    order_id,

    {{ convert_to_usd('amount', 'currency_code') }} as amount_usd

    from {{ ref('stg_orders') }}

    2. Slim CI: The Pro Way to Test

    Running your entire dbt project on every PR is slow and expensive. Slim CI only runs models that have changed and their downstream dependencies.

    On Aivena Data OS, we support dbt clone and state-based selection. When a developer opens a PR, Aivena spins up an Ephemeral Environment, clones the production state, and runs:

    bash

    dbt run --select state:modified+ --state prod_artifacts/

    This reduces CI time from 30 minutes to 30 seconds.

    3. Data Quality Gates with Great Expectations

    Beyond simple unique and not_null tests, Aivena allows you to integrate Great Expectations as a node in your pipeline. If a data quality test fails (e.g., "95% of orders must have a valid zip code"), the pipeline stops before the corrupted data reaches your executive dashboards.

    Aivena + dbt: The Zero-Ops Transformation Layer

    Aivena Data OS provides a managed dbt runner environment:

    * Auto-Documentation: Host your dbt docs site with one click, secured by SSO.

    * Audit Logging: Every dbt run is logged with full stdout/stderr and resource usage.

    * Managed Connections: No more .dbt/profiles.yml secrets management. Aivena injects connection strings directly into the runner.


    Ready to professionalize your SQL? Deploy dbt and ClickHouse on Aivena Data OS today.