<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Saideep Uikey on Medium]]></title>
        <description><![CDATA[Stories by Saideep Uikey on Medium]]></description>
        <link>https://medium.com/@saideep.uikey2010?source=rss-cd5174981dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Vv0HtscI442OsZFiJi3kLA.jpeg</url>
            <title>Stories by Saideep Uikey on Medium</title>
            <link>https://medium.com/@saideep.uikey2010?source=rss-cd5174981dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 16:53:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saideep.uikey2010/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Practical Blueprint for Building a Data System: Reliability, Scalability and Maintainability]]></title>
            <link>https://medium.com/towards-data-engineering/the-practical-blueprint-for-building-a-data-system-reliability-scalability-and-maintainability-46be8d5cedef?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/46be8d5cedef</guid>
            <category><![CDATA[data-architecture]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 04:33:23 GMT</pubDate>
            <atom:updated>2026-10-16T04:33:23.564Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to design production data systems built for fault tolerance, high throughput and effortless long-term operations.</h3><p>Every growing company hits a predictable crisis point: transactional database read replicas begin to buckle under analytical queries, ad-hoc spreadsheets drift out of sync and executive leadership asks: <em>“Why do two different dashboards show conflicting revenue numbers?”</em></p><p>This is usually when engineering teams are asked to “build a modern data platform.”</p><p>The most common mistake at this junction is chasing hype, stitching together ten disparate bleeding-edge tools without a understandable and clear framework. To build a system that stands the test of time, you need to anchor your design around the three core principles that govern all data-intensive applications:</p><ol><li><strong>Reliability:</strong> Tolerating faults and delivering trustworthy, correct data even when things go wrong.</li><li><strong>Scalability:</strong> Gracefully managing increases in data volume, ingestion throughput and analytical query complexity.</li><li><strong>Maintainability:</strong> Enabling engineering teams to easily operate, debug, test and evolve the system over time.</li></ol><p>Here is an architectural blueprint for translating these three non-negotiable principles into a production-grade data system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sn8RxFQWN-1ayuRJk7XIoQ.png" /><figcaption>Data System Architecture</figcaption></figure><h3>Pillar 1: Reliability (Fault Tolerance &amp; Integrity)</h3><p>A reliable data system continues to perform correctly at the desired level of performance even in the face of hardware, network, software or human errors.</p><p>In data systems, reliability goes far beyond basic uptime (“did the orchestrator stay up?”). It directly concerns <strong>data trust</strong>.</p><ul><li><strong>Idempotency and Atomic Operations:</strong> Transient network drops and upstream API rate limits are inevitable. Every pipeline step must be idempotent, meaning re-running an ingestion or transformation task for the same partition window produces the exact same outcome. Use partition overwrites, staging-swap mechanisms or merge/upsert operations rather than raw append patterns.</li><li><strong>Log-Based Change Data Capture (CDC):</strong> Polling operational databases with updated_at &gt; timestamp queries silently fails on hard deletes and can miss updates during transaction rollbacks. Log-based CDC reads transactional write-ahead logs (WAL/binlogs), guaranteeing complete, non-invasive capture of database mutations.</li><li><strong>Contract-Enforced Ingestion:</strong> Bad data will leak downstream unless caught at the gate. Define explicit schemas and data contracts at ingestion boundaries. If an upstream service sends malformed JSON or invalid types, divert those records into dead-letter queues (DLQs) rather than crashing the batch or silently corrupting downstream tables.</li></ul><h3>Pillar 2: Scalability (Handling Load &amp; Latency)</h3><p>Scalability is not a one-size-fits-all metric. It is the system’s ability to remain reliable when specific load parameters such as ingestion volume, concurrent queries or analytical complexity increase.</p><p>When scaling a platform, you typically face three distinct friction points:</p><ul><li><strong>Ingestion Throughput Bottlenecks:</strong> When heavy bulk queries lock transactional databases, decouple extraction from transformation entirely. Ingest directly to object storage as raw, append only streams without running compute heavy jobs against primary operational nodes.</li><li><strong>Storage and Scan Costs:</strong> Full-table scans on terabyte-scale datasets explode warehouse bills. Apply aggressive partitioning (by date) and clustering (by high-cardinality query keys like tenant_id or user_id) so queries only scan the exact micro-partitions they need.</li><li><strong>Compute Contention:</strong> Analytical ad-hoc exploration should never compete with production SLA pipelines or executive dashboards. Separate compute engines: isolate warehouse clusters dedicated to transformation workloads from BI serving endpoints.</li></ul><h4>The Three-Zone Storage Hierarchy</h4><p>To decouple storage costs from compute scalability, organize your lakehouse or warehouse into three distinct zones:</p><ul><li><strong>Bronze (Raw Zone):</strong> An immutable, append only mirror of source systems. Low schema rigidity, preserving raw metadata, payloads and arrival timestamps so data can always be reprocessed from scratch.</li><li><strong>Silver (Conformed Zone):</strong> Cleaned, deduplicated and typed entity models. Business logic is minimal; the focus is standardizing types, resolving primary keys and conforming dimensions across disparate systems.</li><li><strong>Gold (Business Marts):</strong> Aggregated, dimensionally modeled reporting tables (star/snowflake schemas). Optimized specifically for low-latency BI dashboards and analyst querying with tight contract enforcement.</li></ul><h3>Pillar 3: Maintainability (Operability, Simplicity &amp; Evolvability)</h3><p>Over 70% of a data platform’s total lifecycle cost comes from ongoing maintenance: debugging unexpected schema shifts, refactoring brittle queries, onboarding new engineers and resolving silent data decay.</p><p>To build a maintainable data system, apply core software engineering practices to data pipelines:</p><ul><li><strong>Modularity with Data-as-Code:</strong> Replace monolithic 500-line stored procedures with modular, version-controlled transformations (e.g. using frameworks like dbt). Every transformation should have an explicit dependency graph (ref()), making lineage visible and blast radiuses predictable.</li><li><strong>Automated CI/CD Validation:</strong> Never deploy transformation logic directly to production. Use CI pipelines to test branch code against staging environments with synthetic or masked data before merging.</li><li><strong>Data Observability Over Basic Monitoring:</strong> A green pipeline status does not guarantee accurate data. Pair pipeline monitoring (runtime, memory usage, task exits) with automated data quality assertions like:<br>- <strong>Freshness SLAs:</strong> Alerting before downstream users realize a table hasn’t refreshed.<br>- <strong>Distribution checks:</strong> Flagging sudden shifts in row count, unexpected null values or duplicate keys.</li></ul><h3>The Architecture Scorecard</h3><blockquote><strong><em>Reliability Checklist</em></strong></blockquote><blockquote><em>• Can we trust the numbers even when jobs fail?</em></blockquote><blockquote><em>• </em>Key implementations:<em> Log-based CDC, dead-letter queues, idempotent writes and automated schema validation.</em></blockquote><blockquote>— — — — — — — — — — — — — — — — — — — — — —</blockquote><blockquote><strong><em>Scalability Checklist</em></strong></blockquote><blockquote><em>• What happens when data volume or concurrent users grow 10x?</em></blockquote><blockquote><em>• </em>Key implementations:<em> Decoupled compute/storage, multi-zone storage model (Bronze/Silver/Gold) and partition pruning.</em></blockquote><blockquote>— — — — — — — — — — — — — — — — — — — — — —</blockquote><blockquote><strong><em>Maintainability Checklist</em></strong></blockquote><blockquote><em>• Can an on-call engineer easily debug this pipeline at 2 AM?</em></blockquote><blockquote><em>• </em>Key implementations:<em> Version-controlled transformations, explicit DAG lineage, automated CI/CD checks and end-to-end data observability.</em></blockquote><h3>Final Thoughts</h3><p>A great data system is not defined by how many sophisticated distributed engines it runs. It is defined by whether business stakeholders can query metrics without second-guessing their accuracy, whether developers can deploy modifications without breaking dependencies and whether the system can absorb next year’s growth without a total rewrite.</p><p>Prioritize <strong>Reliability, Scalability and Maintainability</strong> from day one and the platform will take care of the rest.</p><p>#DataEngineering #ModernDataStack #DataArchitecture #Reliability #Scalability #SoftwareEngineering</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46be8d5cedef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/the-practical-blueprint-for-building-a-data-system-reliability-scalability-and-maintainability-46be8d5cedef">The Practical Blueprint for Building a Data System: Reliability, Scalability and Maintainability</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying dbt Materializations: The Definitive Guide to your Data Platform Cost, Speed and Scale]]></title>
            <link>https://medium.com/towards-data-engineering/demystifying-dbt-materializations-the-definitive-guide-to-your-data-platform-cost-speed-and-scale-220fbcf6dfc3?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/220fbcf6dfc3</guid>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-architecture]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 11:56:01 GMT</pubDate>
            <atom:updated>2026-09-27T11:56:01.817Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stop burning warehouse compute: How to choose the right persistence layer in dbt</h3><p>If you write transformations in dbt then you already know the magic of {{ ref(&#39;my_model&#39;) }} but beneath that declarative syntax sits a single configuration setting that dictates warehouse storage costs, dashboard latency and pipeline runtimes i.e. <strong>Materializations</strong>.</p><p>A materialization defines how dbt persists your model’s SQL transformations inside the target data warehouse (like Snowflake, BigQuery, Databricks, Redshift, Postgres). Pick the wrong one and you’ll either lock up your dashboard users with spinning loaders or blow through compute credits during overnight batch runs.</p><p>Let’s dissect the built-in materializations, how they operate under the hood and how to choose the right one for your data pipeline.</p><h3>The Big Five Materializations</h3><pre>Materialization   Warehouse Object   Computes At   Storage Cost   Query Speed<br>─────────────────────────────────────────────────────────────────────────────<br>view              Virtual View       Read-time     None           Slow<br>table             Physical Table     Write-time    Standard       Fast<br>incremental       Table + Merge      Write-time    Standard       Fast<br>ephemeral         Inline CTE         Read-time     None           Varies<br>materialized_view Engine Cache       Background    Managed        Fast</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmcPKXAb43qz6uXDk4d1ew.png" /><figcaption>dbt Materialization Strategy</figcaption></figure><h3>1. View: The Read-Time Transformer</h3><p>The view materialization is dbt’s default. Running a model configured as a view doesn&#39;t process or physically write rows to disk, instead dbt stores the query definition in your database catalogue:</p><pre>{{ config(materialized=&#39;view&#39;) }}<br><br>SELECT <br>    order_id,<br>    customer_id,<br>    status,<br>    order_date<br>FROM {{ source(&#39;raw_store&#39;, &#39;orders&#39;) }}<br>WHERE status != &#39;deleted&#39;</pre><ul><li><strong>Under the hood:</strong> dbt executes a standard CREATE OR REPLACE VIEW &lt;schema&gt;.&lt;model_name&gt; AS SELECT ....</li><li><strong>When to use:</strong> Staging models (stg_), lightweight recasting, column renaming and dev environments.</li><li><strong>The drawback:</strong> Query latency shifts downstream. If you stack multiple views on top of each other and wire them to a Tableau or Looker or Power BI dashboard, the engine evaluates the full chain on every dashboard refresh.</li></ul><h3>2. Table: The Gold Standard for Marts</h3><p>A table forces dbt to calculate all transformations at build time and write the output permanently to disk.</p><pre>{{ config(materialized=&#39;table&#39;) }}<br><br>SELECT <br>    customer_id,<br>    count(order_id) AS total_orders,<br>    sum(order_amount) AS lifetime_spend<br>FROM {{ ref(&#39;stg_orders&#39;) }}<br>GROUP BY 1</pre><ul><li><strong>Under the hood:</strong> dbt creates a new table via CREATE TABLE &lt;model_name&gt; AS SELECT ... (often buffering through an atomic swap or temporary table depending on the database adapter).</li><li><strong>When to use:</strong> Core analytics marts (fct_, dim_) accessed directly by Data Analyst, Business Analysts and Reporting tools.</li><li><strong>The drawback:</strong> Long build times. Every single dbt run drops and recreates the entire dataset from scratch, burning warehouse compute on data that may not have changed.</li></ul><h3>3. Incremental: Scaling to Big Data</h3><p>When processing millions or billions of rows, full table refreshes become economically and computationally unviable. The incremental materialization allows dbt to process only data that has arrived or changed since the prior run.</p><pre>{{<br>    config(<br>        materialized=&#39;incremental&#39;,<br>        unique_key=&#39;order_id&#39;,<br>        incremental_strategy=&#39;merge&#39;<br>    )<br>}}<br><br>SELECT<br>    order_id,<br>    customer_id,<br>    order_status,<br>    updated_at<br>FROM {{ ref(&#39;stg_orders&#39;) }}<br>{% if is_incremental() %}<br>    -- Filter out unchanged records during regular runs<br>    WHERE updated_at &gt; (SELECT max(updated_at) FROM {{ this }})<br>{% endif %}</pre><ul><li><strong>Under the hood:</strong> On the first execution, dbt runs a standard full build. On subsequent runs, is_incremental() evaluates to True, queries only the delta records, creates a temporary staging table and performs an upsert/merge into {{ this }}.</li><li><strong>When to use:</strong> Immutable append-only log data, event streams, clickstream pipelines and web analytics tables.</li><li><strong>The drawback:</strong> Operational overhead. Handling late-arriving data, schema evolution and backfills requires proactive design and occasional --full-refresh runs.</li></ul><h3>4. Ephemeral: Modularity Without the Clutter</h3><p>Ephemeral models are not saved in the database schema at all. They are Jinja-compiled directly into downstream dependent models as a Common Table Expression (CTE).</p><pre>-- models/staging/stg_product.sql<br>{{ config(materialized=&#39;ephemeral&#39;) }}<br><br>SELECT id,<br>      product_code,<br>      product_name<br>FROM (<br>  SELECT<br>      id,<br>      product_code<br>      product_name,<br>      ROW_NUMBER() OVER(PARTITION BY product_code ORDER BY modified_dt DESC) AS rn<br>  FROM {{ source(&#39;seed_data&#39;, &#39;product&#39;) }}<br>  ) AS x<br>WHERE x.rn = 1</pre><p>If model fct_orders.sql references this model via {{ ref(&#39;stg_product&#39;) }}, dbt compiles the final SQL at the runtime.</p><pre>-- models/marts/fct_orders.sql<br>SELECT<br>    o.order_id,<br>    p.product_id,<br>    c.customer_id,<br>    o.order_quantity,<br>    o.order_amount<br>FROM {{ ref(&#39;orders&#39;) }} AS o<br>INNER JOIN {{ ref(&#39;stg_product&#39;) }} AS p<br>  ON o.product__id = p.product_id<br>INNER JOIN {{ ref(&#39;customers&#39;) }} AS c<br>  ON o.customer_id = c.customer_id</pre><p>dbt compiled version of fct_orders.sql model:</p><pre>-- target/compiled/models/marts/fct_orders.sql<br>WITH __dbt__cte__stg_product AS (<br>    SELECT id,<br>      product_code,<br>      product_name<br>    FROM (<br>      SELECT<br>          id,<br>          product_code<br>          product_name,<br>          ROW_NUMBER() OVER(PARTITION BY product_code ORDER BY modified_dt DESC) AS rn<br>      FROM {{ source(&#39;seed_data&#39;, &#39;product&#39;) }}<br>      ) AS x<br>    WHERE x.rn = 1<br>)<br><br>SELECT<br>    o.order_id,<br>    p.product_id,<br>    c.customer_id,<br>    o.order_quantity,<br>    o.order_amount<br>FROM {{ ref(&#39;orders&#39;) }} AS o<br>INNER JOIN __dbt__cte__stg_product AS p<br>  ON o.product__id = p.product_id<br>INNER JOIN {{ ref(&#39;customers&#39;) }} AS c<br>  ON o.customer_id = c.customer_id</pre><ul><li><strong>When to use:</strong> Reusable internal calculations or helper logic shared between only a few models that you don’t want cluttering warehouse schemas.</li><li><strong>The drawback:</strong> Downstream models can become unwieldy to inspect and debug. You cannot inspect an ephemeral model in a database IDE without running the parent query.</li></ul><h3>5. Materialized View: Engine-Level Hybrid</h3><p>Introduced natively to dbt, materialized_view allows you to leverage warehouse-specific materialized view implementations (e.g., Snowflake, BigQuery, Databricks, PostgreSQL).</p><pre>-- models/marts/fct_orders.sql<br>{{<br>    config(<br>        materialized=&#39;materialized_view&#39;<br>    )<br>}}<br><br>SELECT <br>    DATE_TRUNC(&#39;day&#39;, order_date) AS order_day,<br>    COUNT(DISTINCT customer_id) AS active_users<br>FROM {{ ref(&#39;fct_orders&#39;) }}<br>GROUP BY 1</pre><ul><li><strong>How it differs from </strong><strong>incremental:</strong> Incremental models rely on dbt orchestrations (like an Airflow or dbt Cloud job) to trigger updates. Materialized views leverage the database&#39;s native engine to maintain the query cache automatically as underlying data lands.</li><li><strong>When to use:</strong> Low-latency aggregation layers where you don’t want to orchestrate high-frequency dbt runs.</li></ul><h3>The Decision Framework: How to Architect Your DAG</h3><p>Don’t over-engineer from day one. The official dbt recommendation offers a clear progression path:</p><pre>Start Here: VIEW<br>             │<br>             ▼<br>    Dashboard slow?<br>      ───► Switch to TABLE<br>             │<br>             ▼<br>    dbt build too slow?<br>      ───► Upgrade to INCREMENTAL / MATERIALIZED VIEW</pre><ul><li><strong>Staging (</strong><strong>stg_):</strong> Keep them as view (or ephemeral for lightweight, one-off logic).</li><li><strong>Intermediate (</strong><strong>int_):</strong> Use view for simple joins; use table if the intermediate model performs heavy aggregations used across multiple marts.</li><li><strong>Marts (</strong><strong>fct_, </strong><strong>dim_):</strong> Default to table for reliable Business Intelligence performance.</li><li><strong>Massive Fact Tables:</strong> Graduate to incremental with appropriate unique_key and clustering keys once full refreshes exceed execution time targets.</li></ul><p>Materialization is where code architecture meets infrastructure budget. By matching each DAG stage to its ideal storage pattern, you ensure snappy dashboards for your stakeholders and predictable compute bills for your engineering team.</p><p>#DataEngineering #dbt #AnalyticsEngineering #SQL #Snowflake #BigQuery</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=220fbcf6dfc3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/demystifying-dbt-materializations-the-definitive-guide-to-your-data-platform-cost-speed-and-scale-220fbcf6dfc3">Demystifying dbt Materializations: The Definitive Guide to your Data Platform Cost, Speed and Scale</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Generic Isn’t Enough: A Practical Guide to dbt Singular Tests]]></title>
            <link>https://medium.com/towards-data-engineering/when-generic-isnt-enough-a-practical-guide-to-dbt-singular-tests-bbedeceef5a0?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbedeceef5a0</guid>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-quality]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Sat, 12 Sep 2026 11:25:11 GMT</pubDate>
            <atom:updated>2026-09-12T11:25:11.732Z</atom:updated>
            <content:encoded><![CDATA[<h3>Every Analytics Engineer starts their testing journey the same way a few lines in schema.yml.</h3><pre>columns:<br>  - name: order_id<br>    data_tests:<br>      - unique<br>      - not_null</pre><p>You run dbt test and gets all green and you sleep calmly.</p><p>Then Monday morning arrives. A stakeholder messages you on Slack-</p><blockquote>“Hey, why do we have negative shipping fees, orders created after they were delivered and customers with active subscriptions but canceled accounts?”</blockquote><p>Generic tests check data integrity: nulls, duplicates, enum matches and foreign keys but they know nothing about your company’s business logic. That is where <strong>singular data tests</strong> step in.</p><h3>What Exactly Is a Singular Test?</h3><p>A singular test is simply a standalone .sql query stored inside your dbt project’s tests/ directory.</p><p>Unlike generic tests (which are parametrized macros invoked via YAML), singular tests are one-off assertions crafted for a specific data validation.</p><p>The mental model behind dbt data testing is simple:</p><blockquote><strong><em>A dbt test passes when the query returns zero rows and fails when it returns one or more rows.</em></strong></blockquote><p>You do not write SQL to find valid records instead you write SQL to <strong>catch bad records</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HoTACnbzBcR8Bfgs7mjU6A.png" /><figcaption>Generic v/s Singular Test</figcaption></figure><h3>Real-World Example: Catching Impossible Math</h3><p>Imagine you run an e-commerce platform. Your reporting relies on fct_orders.</p><p>A critical business rule states:</p><ol><li>order_total must equal subtotal + tax_amount - discount_amount.</li><li>discount_amount should never exceed subtotal.</li></ol><p>You cannot cleanly write that with out-of-the-box accepted_values or not_null.</p><p>Here is how you handle it with a singular test:</p><p>Create tests/assert_order_financials_balance.sql:</p><pre>-- tests/assert_order_financials_balance.sql<br>select<br>    order_id,<br>    subtotal,<br>    tax_amount,<br>    discount_amount,<br>    order_total,<br>    (subtotal + tax_amount - discount_amount) as expected_total<br>from {{ ref(&#39;fct_orders&#39;) }}<br>where <br>    -- Condition 1: Financial reconciliation discrepancy<br>    abs(order_total - (subtotal + tax_amount - discount_amount)) &gt; 0.01<br>    <br>    -- Condition 2: Nonsensical discount<br>    or discount_amount &gt; subtotal</pre><p>When you run:</p><pre>dbt test --select assert_order_financials_balance</pre><p>If everything balances then query returns 0 records and passes. If an upstream bug caused discounts to miscalculate, dbt flags the failure and spits out the offending order_id’s in your compiled run artifacts.</p><h3>Multi-Model Validations: Checking Broken Business Logic</h3><p>Singular tests can use {{ ref(...) }} across multiple tables, making join-level sanity checks trivial.</p><p>Suppose an active customer in dim_customers must always have at least one valid payment record in fct_payments:</p><pre>-- tests/assert_active_customers_have_payments.sql<br>with active_customers as (<br>    select customer_id<br>    from {{ ref(&#39;dim_customers&#39;) }}<br>    where account_status = &#39;active&#39;<br>),<br>payments as (<br>    select distinct customer_id<br>    from {{ ref(&#39;fct_payments&#39;) }}<br>    where payment_status = &#39;settled&#39;<br>)<br>select <br>    c.customer_id<br>from active_customers c<br>left join payments p <br>    on c.customer_id = p.customer_id<br>where p.customer_id is null</pre><p>If any active customer lacks settled payments, this test surfaces them immediately before your executive dashboards refresh.</p><h3>Generic vs. Singular: Which One When?</h3><p>Think of tests in two distinct buckets: structural hygiene versus domain logic.</p><h4>1. Generic Tests (The Structural Guardrails)</h4><ul><li><strong>Where they live:</strong> Defined in schema.yml</li><li><strong>Reusability:</strong> High, apply the same rule across hundreds of columns and models</li><li><strong>Scope:</strong> Single columns, basic relations or standard constraints</li><li><strong>When to reach for them:</strong> Baseline schema validation (unique, not_null, foreign keys, accepted enum values)</li></ul><h4>2. Singular Tests (The Bespoke Business Rules)</h4><ul><li><strong>Where they live:</strong> Standalone .sql files inside the tests/ directory</li><li><strong>Reusability:</strong> Purpose-built for a specific query or workflow</li><li><strong>Scope:</strong> Complex multi-table joins, window functions and arithmetic assertions</li><li><strong>When to reach for them:</strong> Revenue reconciliation, sanity checks across lifecycles and edge-case domain rules</li></ul><blockquote><strong><em>Quick Rule of Thumb:</em></strong></blockquote><blockquote><em>If you want to check </em>whether data exists and follows a standard format.<em> Go for a </em><strong><em>generic test</em></strong><em>.</em></blockquote><blockquote><em>If you want to verify </em>whether the numbers make sense in the real world.<em> Write a </em><strong><em>singular test</em></strong><em>.</em></blockquote><h3>Best Practices for Writing Singular Tests</h3><ul><li><strong>Name the file after what it asserts:</strong> Use prefixes like assert_ or test_ that clearly state the assumption (e.g. assert_subscription_end_after_start.sql).</li><li><strong>Keep queries cheap:</strong> Filter aggressively or run tests only on recent partitions if your marts contain billions of rows.</li><li><strong>Convert repeat patterns to custom generic tests:</strong> If you find yourself writing the exact same singular test across three different models, parameterize it as a custom generic macro in macros/ instead.</li><li><strong>Store failing records in CI:</strong> Run dbt test --store-failures so that you can inspect the exact rows that tripped the wire directly in your warehouse scratch schema.</li></ul><p>Start encoding your domain rules into singular tests, your stakeholders will thank you.</p><p>#dbt #dataengineering #analyticsengineering #sql #dataquality</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbedeceef5a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/when-generic-isnt-enough-a-practical-guide-to-dbt-singular-tests-bbedeceef5a0">When Generic Isn’t Enough: A Practical Guide to dbt Singular Tests</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 4-Line YAML Shield: A Practical Guide to dbt Generic Tests]]></title>
            <link>https://medium.com/towards-data-engineering/the-4-line-yaml-shield-a-practical-guide-to-dbt-generic-tests-706fe6424e64?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/706fe6424e64</guid>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[data-quality]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Sun, 06 Sep 2026 06:37:32 GMT</pubDate>
            <atom:updated>2026-09-06T06:37:32.956Z</atom:updated>
            <content:encoded><![CDATA[<h3>Every Analytics Engineer shares the same recurring nightmare, a CEO standing over their desk asking why the board deck reports two different numbers for active customer count ?</h3><p>90% of the time, the culprit isn’t a complex window function or an upstream API schema shift. It’s an unhandled NULL, a duplicate join or an invalid enum value silently moving from raw ingestion pipeline to transformation pipeline and into your production reporting tables.</p><p>This is where dbt generic tests turn from a “nice-to-have” best practice into non-negotiable defensive engineering.</p><h3>What Actually Is a dbt Generic Test?</h3><p>In dbt, tests are assertions you make about your models. Behind the scene, every test is a parameterised SQL query that returns failing rows.</p><ul><li>If the query returns <strong>0 rows</strong> then test <strong>passes</strong>.</li><li>If the query returns <strong>≥ 1 row</strong> then test <strong>fails</strong> (or warns, depending on your configuration).</li></ul><p>A <strong>generic test</strong> is a templated, reusable query defined in a macro block. Instead of writing custom SQL for every single table, you declare them directly in your .yml schema files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d1s1TQobegkioww20oAMgg.png" /><figcaption>Working of generic tests in dbt</figcaption></figure><h3>The Built-In “Core Four” Generic Tests</h3><p>dbt comes with four generic tests out of the box. Covering your primary and foreign keys with these four handles the vast majority of silent pipeline failures.</p><h4>1. unique</h4><p>Ensures that no column contains duplicate values. Always apply this to surrogate keys and natural primary keys.</p><pre>version: 2<br>models:<br>  - name: dim_customers<br>    columns:<br>      - name: customer_id<br>        tests:<br>          - unique</pre><h4>2. not_null</h4><p>Guarantees a column has no missing values. Vital for IDs, timestamps and core dimension attributes.</p><pre>      - name: customer_id<br>        tests:<br>          - not_null</pre><h4>3. accepted_values</h4><p>Restricts column values to a predefined list. Ideal for status flags, environment tags or payment status.</p><pre>        - name: subscription_status<br>          tests:<br>            - accepted_values:<br>                values: [&#39;active&#39;, &#39;paused&#39;, &#39;churned&#39;, &#39;trial&#39;]</pre><h4>4. relationships</h4><p>Validates referential integrity between tables. It asserts that every foreign key in your child table exists in the parent dimension table.</p><pre>      - name: plan_id<br>        tests:<br>          - relationships:<br>              to: ref(&#39;dim_plans&#39;)<br>              field: plan_id</pre><h3>Level Up: Custom Generic Tests</h3><p>When the built-in four aren’t enough, you don’t need to write separate singular tests for each model. You can write your own generic test macro inside your macros/ folder.</p><p>Here is an example checking that numeric columns are strictly positive-</p><pre>{% test is_positive(model, column_name) %}<br>select<br>    {{ column_name }} as invalid_value<br>from {{ model }}<br>where {{ column_name }} &lt;= 0<br>{% endtest %}</pre><p>Now, reuse it across any model in your project:</p><pre>version: 2<br>models:<br>  - name: fct_orders<br>    columns:<br>      - name: total_amount_usd<br>        tests:<br>          - is_positive</pre><h3>Best Practices-</h3><blockquote><strong>1. Test primary keys on arrival</strong>: Every silver/staging table should have unique and not_null on its grain. Catching bad upstream data early prevents expensive transformation retries.</blockquote><blockquote><strong>2. Use severity thresholds intentionally</strong>: Not all failures require halting the deployment. Use severity: warn with an error_if threshold on edge-case dimensions, reserving hard failures (severity: error) for financial and user-identity models.</blockquote><blockquote><strong>3. Extend with </strong><a href="https://hub.getdbt.com/metaplane/dbt_expectations/latest/"><strong>dbt-expectations</strong></a>: Before building complex custom macros, check packages like Great Expectations for dbt (calogica/dbt-expectations) . It provides out-of-the-box generic tests for string regex, column distributions and date ranges.</blockquote><p>Treat your data models like software applications like write unit tests, test your schemas continuously and never let production dashboards be the place where broken contracts are discovered.</p><p>#dataengineering #dbt #analyticsengineering #sql #dataquality</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=706fe6424e64" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/the-4-line-yaml-shield-a-practical-guide-to-dbt-generic-tests-706fe6424e64">The 4-Line YAML Shield: A Practical Guide to dbt Generic Tests</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Serving Stale Data: A Practical Guide to dbt Freshness Checks]]></title>
            <link>https://medium.com/@saideep.uikey2010/stop-serving-stale-data-a-practical-guide-to-dbt-freshness-checks-eb3ebcc4a47e?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb3ebcc4a47e</guid>
            <category><![CDATA[data-quality]]></category>
            <category><![CDATA[dataops]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Thu, 27 Aug 2026 18:03:30 GMT</pubDate>
            <atom:updated>2026-08-27T18:03:30.568Z</atom:updated>
            <content:encoded><![CDATA[<p>Every Analytics Engineer has lived this nightmare: your pipelines passed, your models ran without throwing errors and downstream dashboards display fresh and clean visualisations then suddenly a VP messages you —</p><blockquote><em>“Why are yesterday’s signups showing zero?”</em></blockquote><p>The transformations executed flawlessly but the underlying data hadn’t moved in days.</p><h3>The Silent Killer: Data Staleness</h3><p>Pipeline failures are noisy and easy to catch. Data staleness is dangerous precisely because it is quiet. An upstream extraction job hangs, an API rate-limits silently or a webhook drops and your downstream models keep aggregating old snapshots into “fresh” reports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bK6M9B2BzsEP1SUlMpkLlQ.png" /></figure><p>To solve this, dbt provides built-in source freshness testing.</p><h3>1. Defining Freshness in YAML</h3><p>Configure freshness directly within your sources.yml definitions using explicit time thresholds:</p><pre>version: 2<br>sources:<br>  - name: stripe_billing<br>    database: raw<br>    schema: stripe<br>    freshness:<br>      warn_after: {count: 12, period: hour}<br>      error_after: {count: 24, period: hour}<br>    loaded_at_field: _fivetran_synced<br>    tables:<br>      - name: charges<br>      - name: subscriptions</pre><ul><li><strong>loaded_at_field</strong>: The timestamp column tracking when the row arrived in your warehouse.</li><li><strong>warn_after &amp; </strong><strong>error_after</strong>: Grace periods before dbt raises an alert or fails the step.</li></ul><h3>2. Running Freshness Checks in Orchestration</h3><p>Execute freshness checks at the start in your schedule:</p><pre>dbt source freshness</pre><p>You can selectively run downstream models only when their upstream sources are fresh by pairing state selection with freshness metadata:</p><pre>dbt build --select &quot;source_status:fresher+&quot;</pre><h3>Key Takeaways</h3><ul><li><strong>Check Before You Build:</strong> Run freshness tests at the start of your DAG to avoid wasting compute on stale inputs.</li><li><strong>Set Business-aligned Thresholds:</strong> Hourly event logs need tighter freshness bounds than daily CRM syncs.</li><li><strong>Fail Loudly:</strong> Hook your orchestration alerts to Slack so you catch stale sources before your stakeholders do.</li></ul><p>#DataEngineering #AnalyticsEngineering #DataOps #ModernDataStack #dbt #dbtTips #DataQuality #DataPipelines #DataGovernance</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb3ebcc4a47e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering dbt Docs Blocks: How to Build Clean, DRY and Scalable Data Catalogs]]></title>
            <link>https://medium.com/@saideep.uikey2010/mastering-dbt-docs-blocks-how-to-build-clean-dry-and-scalable-data-catalogs-e21a7f65a833?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e21a7f65a833</guid>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[modern-data-stack]]></category>
            <category><![CDATA[data-modeling]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Thu, 20 Aug 2026 18:40:10 GMT</pubDate>
            <atom:updated>2026-08-20T18:41:32.779Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Stop copy-pasting descriptions across dozens of YAML files. Here is your definitive guide to leveraging Markdown </em><em>docs blocks in dbt.</em></p><p>As analytics codebases grow from 20 models to 500+, documentation is often the first thing that breaks.</p><p>You’ve likely seen this before:</p><ul><li>user_id is defined as <em>&quot;User unique identifier&quot;</em> in staging, <em>&quot;Customer ID&quot;</em> in intermediate and <em>&quot;Primary key for account&quot;</em> in marts.</li><li>Complex KPI definitions (like <em>Monthly Recurring Revenue</em> or <em>Rolling Churn</em>) have slightly different formulas written across five different YAML files.</li><li>Someone updates the definition of an enterprise KPI in one model, forgetting to update the other seven models referencing it.</li></ul><p>In software engineering, we treat duplication as technical debt (<strong>DRY - Don’t Repeat Yourself</strong>). Documentation in modern data modeling deserves the exact same engineering standard.</p><p>That is where <strong>dbt Docs Blocks</strong> come in.</p><h3>What is a dbt Docs Block?</h3><p>A <strong>Docs Block</strong> is a Jinja-powered markdown snippet enclosed between {% docs &lt;block_name&gt; %} and {% enddocs %} tags.</p><p>These blocks live inside .md files within your dbt project (typically inside your models/ directory or a dedicated docs/ folder). Once defined, they can be referenced inside any YAML configuration using the doc() Jinja function:</p><pre>description: &#39;{{ doc(&quot;block_name&quot;) }}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WelFbzyUray4rxRghlquUg.png" /></figure><p>When you run dbt docs generate, dbt compiles the markdown from the block directly into the target model, column or source documentation in your dbt catalog.</p><h3>Step-by-Step Implementation</h3><h4>Step 1: Set Up Your Directory Structure</h4><p>While you can name your file docs_blocks.md and drop it anywhere in models/, structuring your docs logically keeps large projects maintainable:</p><pre>my_dbt_project/<br>├── models/<br>│   ├── staging/<br>│   ├── intermediate/<br>│   ├── marts/<br>│   └── docs/<br>│       ├── common_columns.md      # Shared IDs, timestamps, status flags<br>│       ├── business_kpis.md       # Complex metrics (ARR, Churn, CAC)<br>│       └── model_overviews.md     # Long-form markdown for marts<br>├── dbt_project.yml<br>└── packages.yml</pre><blockquote><strong><em>Tip:</em></strong><em> Ensure your </em><em>dbt_project.yml includes the path to your docs directory in </em><em>model-paths or </em><em>docs-paths.</em></blockquote><h4>Step 2: Write Your Markdown Blocks</h4><p>Create reusable definitions inside your markdown files. Markdown gives you the superpower of adding rich text, code blocks, lists and tables without wrestling with YAML formatting issues.</p><p><strong>models/docs/common_columns.md</strong></p><pre>{% docs col_user_id %}<br>The surrogate or natural primary key uniquely identifying a platform user. <br>- **Format:** UUIDv4 string<br>- **Source:** Upstream `auth_service.users.id`<br>- **Nullable:** No (Enforced via `not_null` test)<br>{% enddocs %}<br><br>{% docs col_created_at_utc %}<br>Timestamp recorded in **UTC** when the entity was first inserted into the database.<br>{% enddocs %}<br><br>{% docs col_order_status %}<br>Current lifecycle state of the order:<br>| Status | Description |<br>| :--- | :--- |<br>| `pending` | Order created; payment not yet captured |<br>| `processing` | Payment confirmed; awaiting fulfillment |<br>| `fulfilled` | Shipped to customer |<br>| `cancelled` | Cancelled by user or fraud detection |<br>| `refunded` | Payment reversed |<br>{% enddocs %}</pre><p><strong>models/docs/business_kpis.md</strong></p><pre>{% docs kpi_active_user %}<br>### Active User Definition (Canonical)<br>A user is considered **Active** within a given period $T$ if they have completed at least one *Qualifying Event*:<br>1. Logged into the web/mobile app (`event_name = &#39;user_login&#39;`)<br>2. Initiated an API request with an active bearer token<br>3. Completed a checkout transaction<br><br>{% enddocs %}</pre><h4>Step 3: Reference the Blocks in Schema YAML</h4><p>Now reference your blocks inside _models.yml or _sources.yml files using &#39;{{ doc(&quot;block_name&quot;) }}&#39;:</p><pre>version: 2<br>models:<br>  - name: fct_orders<br>    description: &quot;Atomic-level fact table containing all completed and in-flight customer orders.&quot;<br>    columns:<br>      - name: order_id<br>        description: &quot;Primary key for the order.&quot;<br>        tests:<br>          - unique<br>          - not_null<br>      - name: user_id<br>        description: &#39;{{ doc(&quot;col_user_id&quot;) }}&#39;<br>        tests:<br>          - relationships:<br>              to: ref(&#39;dim_users&#39;)<br>              field: user_id<br>      - name: order_status<br>        description: &#39;{{ doc(&quot;col_order_status&quot;) }}&#39;<br>      - name: created_at<br>        description: &#39;{{ doc(&quot;col_created_at_utc&quot;) }}&#39;<br>  - name: dim_users<br>    description: &#39;{{ doc(&quot;kpi_active_user&quot;) }}&#39;<br>    columns:<br>      - name: user_id<br>        description: &#39;{{ doc(&quot;col_user_id&quot;) }}&#39;<br>      - name: created_at<br>        description: &#39;{{ doc(&quot;col_created_at_utc&quot;) }}&#39;</pre><h3>Four Best Practices for Enterprise dbt Projects</h3><h4>1. Establish Naming Conventions</h4><p>Avoid name collisions by prefixing your docs block identifiers:</p><ul><li>col_ for shared column descriptions (col_account_id, col_updated_at)</li><li>model_ for model-level overviews (model_fct_subscriptions)</li><li>metric_ or kpi_ for shared business metric calculations (metric_ltv)</li></ul><h4>2. Leverage Markdown Tables &amp; Callouts</h4><p>YAML multiline strings (| or &gt;) are notorious for indentation errors. By offloading complex descriptions into markdown docs blocks, you can safely write rich markdown tables, checklists, links to internal Notion/Confluence pages and data lineage notes.</p><h4>3. Use Docs Blocks for Source System Descriptions</h4><p>Data consumers and analytics engineers frequently need context on raw sources. Add docs blocks to describe source databases, CDC (Change Data Capture) lag and SLA guarantees in sources.yml.</p><h4>4. Combine with CI/CD Linting</h4><p>Use tools like dbt-checkpoint or SQLFluff pre-commit hooks to enforce that critical columns (e.g., user_id, transaction_id) always have a description attached.</p><h3>Summary</h3><p>Documentation should not be a chore that is written once and forgotten. By adopting docs_blocks.md files:</p><ul><li>You eliminate redundant YAML copy-pasting.</li><li>You maintain a single general source of truth for business definitions.</li><li>Your dbt documentation site transforms into a clean, stakeholder-ready data dictionary.</li></ul><p><em>What strategies does your team use to keep dbt documentation clean and reliable? Let’s connect in the comments below!</em></p><p>#dbt #dbtCore #AnalyticsEngineering #DataDocumentation #DataOps #DataModeling #DataEngineering #ModernDataStack #DataGovernance #SQL #DataCatalog</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e21a7f65a833" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Hardcoding SQL Logic: A Practical Guide to dbt Seeds]]></title>
            <link>https://medium.com/@saideep.uikey2010/stop-hardcoding-sql-logic-a-practical-guide-to-dbt-seeds-96c27869e34c?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/96c27869e34c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Fri, 14 Aug 2026 01:10:19 GMT</pubDate>
            <atom:updated>2026-08-14T03:28:22.375Z</atom:updated>
            <content:encoded><![CDATA[<p>How to turn fragile mapping logic into clean, version-controlled, testable reference tables inside your modern data stack ?</p><h3>Introduction</h3><p>If you’ve spent more than a week in analytics engineering, you’ve likely encountered SQL models bloated with massive CASE WHEN statements, inline VALUES () clauses or messy unmaintained Excel Sheet extracts.</p><p>Hardcoding reference logic directly inside your data transformations creates brittle pipelines. When a business definition changes — say, a new product category is added or a country code changes — you’re forced to hunt down every model where that logic was written.</p><p>That is where <strong>dbt seeds</strong> shine.</p><h3>What Exactly Are dbt Seeds?</h3><p>In dbt, <strong>seeds</strong> are static CSV files that live directly inside your dbt repository (typically under the seeds/ folder). When you run the CLI command dbt seed, dbt parses those CSVs and loads them directly into your target data warehouse schema as physical tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b9eD1MZ28HNAjO2JP8yGHw.png" /></figure><p>Once loaded you can reference a seed table using dbt’s standard ref() function, treating it identically to any other staging or intermediate model.</p><pre>dbt Project Structure<br>├── dbt_project.yml<br>├── models/<br>└── seeds/<br>    └── country_region_mapping.csv  &lt;-- Your Seed</pre><h3>3 Reasons Why Seeds Outshine Hardcoded SQL</h3><ul><li><strong>Version Control for Static Data:</strong> Because seed CSVs live inside your Git repository, every addition, edit or deletion to a business mapping is tracked via pull requests.</li><li><strong>Environment Portability:</strong> Whether a developer is spinning up a fresh sandbox or deploying to production, running dbt seed ensures reference tables are automatically available across all environments.</li><li><strong>Full Testing &amp; Documentation Capabilities:</strong> Just like models, seeds can be configured in your schema.yml file. You can apply generic tests (unique, not_null) and document column definitions so the entire team understands the business context.</li></ul><h3>Step-by-Step: Setting Up Your First dbt Seed</h3><h4>Step 1: Create the CSV File</h4><p>Inside your dbt project’s seeds/ directory, create a file named order_statuses.csv:</p><pre>status_code,status_name,is_active<br>P,Pending,true<br>S,Shipped,true<br>D,Delivered,true<br>C,Cancelled,false</pre><h4>Step 2: Configure &amp; Test Your Seed in YAML</h4><p>Create a seeds.yml file inside the seeds/ directory to enforce data quality and explicitly cast column data types (a critical best practice to avoid warehouse type-inference bugs):</p><pre>version: 2<br>seeds:<br>  - name: order_statuses<br>    description: &quot;Lookup mapping for raw e-commerce order statuses.&quot;<br>    config:<br>      column_types:<br>        status_code: varchar(5)<br>        status_name: varchar(50)<br>        is_active: boolean<br>    columns:<br>      - name: status_code<br>        tests:<br>          - unique<br>          - not_null</pre><h4>Step 3: Run the Seed Command</h4><p>Execute the following command in your terminal:</p><pre>dbt seed</pre><p>dbt will create the order_statuses table in your data warehouse and populate it with the CSV rows.</p><h4>Step 4: Use the Seed in Your Models</h4><p>Now, replace those fragile CASE WHEN blocks in your SQL models with a clean LEFT JOIN:</p><pre>-- models/marts/fct_orders.sql<br>WITH raw_orders AS (<br>    SELECT * FROM {{ ref(&#39;stg_orders&#39;) }}<br>),<br><br>status_lookup AS (<br>    SELECT * FROM {{ ref(&#39;order_statuses&#39;) }}<br>)<br><br>SELECT <br>    o.order_id,<br>    o.customer_id,<br>    s.status_name,<br>    o.order_amount<br>FROM raw_orders o<br>LEFT JOIN status_lookup s <br>    ON o.status_code = s.status_code</pre><h3>Best Practices &amp; Pitfalls to Avoid</h3><p>Do This ✅</p><ul><li><strong>Keep seeds small:</strong> Use seeds strictly for static, low-cardinality reference data (e.g., &lt; 1,000 rows).</li><li><strong>Enforce column types:</strong> Explicitly declare column types in schema.yml to prevent unexpected warehouse casting behavior.</li><li><strong>Use </strong><strong>--full-refresh when changing schemas:</strong> If you modify seed CSV headers or column structure, run dbt seed --full-refresh to rebuild the underlying target table.</li></ul><p>Avoid This ❌</p><ul><li><strong>Don’t use seeds as an ETL tool:</strong> Never load large historical transaction files or frequently updating data via seeds.</li><li><strong>Don’t store sensitive data:</strong> Since seed files are committed to Git, never put personal identifable information, credentials or confidential business details in a CSV.</li><li><strong>Don’t skip testing:</strong> Always add basic unique and not_null primary key tests to your seed configuration.</li></ul><h3>Final Thoughts</h3><p>dbt seeds are one of those features that quietly elevate a project from “a collection of SQL scripts” to a production-grade analytics engineering system. By turning manual lookup logic into version-controlled data assets, you make your codebase cleaner, safer and infinitely easier to maintain.</p><p>#DataEngineering #AnalyticsEngineering #dbt #SQL #DataAnalytics</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96c27869e34c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Repeating Yourself: A Practical Guide to dbt Macros]]></title>
            <link>https://medium.com/@saideep.uikey2010/stop-repeating-yourself-a-practical-guide-to-dbt-macros-cdd2a44191cf?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdd2a44191cf</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Fri, 07 Aug 2026 01:36:41 GMT</pubDate>
            <atom:updated>2026-08-07T01:59:05.470Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve spent any time working in Analytics Engineering, you know how quickly SQL codebases can become bloated. You start with clean transformation pipelines but soon you’re copying and pasting the same CASE WHEN statements, JSON extractions or date formatting logic across dozens of models.</p><p>This violates one of the fundamental principles of software engineering: <strong>DRY (Don’t Repeat Yourself)</strong>.</p><p>Thankfully <strong>dbt (data build tool)</strong> provides a powerful abstraction layer to solve this problem: <strong>Macros</strong>.</p><h3>What is a dbt Macro?</h3><p>In simple terms, a dbt macro is a reusable block of code — written using the <strong>Jinja</strong> templating engine alongside SQL — that functions similarly to a function in Python or any other programming language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RwlFqEutoYvx-sRAGWLg5w.png" /></figure><p>Instead of hardcoding complex operations in multiple SQL files, you write the logic once in a .sql file inside your project’s macros/ directory and call it wherever needed.</p><pre>dbt_project/<br>├── models/<br>│   ├── staging/<br>│   └── marts/<br>└── macros/<br>    └── cents_to_dollars.sql</pre><h3>Anatomy of a dbt Macro</h3><p>Macros are wrapped in {% macro %} and {% endmacro %} tags. They can accept parameters, evaluate control flow logic (if/else conditions, loops) and output raw SQL.</p><p>Here is a straightforward example that converts monetary amounts from cents to dollars:</p><pre>-- macros/cents_to_dollars.sql<br>{% macro cents_to_dollars(column_name, decimal_places=2) %}<br>    round(cast({{ column_name }} as numeric) / 100.0, {{ decimal_places }})<br>{% endmacro %}</pre><h3>Calling the Macro in a Model</h3><p>Inside any dbt model file you invoke the macro using Jinja expression syntax {{ ... }}:</p><pre>-- models/marts/fct_orders.sql<br>select<br>    order_id,<br>    customer_id,<br>    {{ cents_to_dollars(&#39;order_total_cents&#39;) }} as order_total_usd,<br>    {{ cents_to_dollars(&#39;tax_amount_cents&#39;, 4) }} as tax_amount_usd<br>from {{ ref(&#39;stg_orders&#39;) }}</pre><p>When you run dbt compile or dbt run, dbt renders this code into compiled SQL before executing it on your data warehouse:</p><pre>-- Compiled SQL target output<br>select<br>    order_id,<br>    customer_id,<br>    round(cast(order_total_cents as numeric) / 100.0, 2) as order_total_usd,<br>    round(cast(tax_amount_cents as numeric) / 100.0, 4) as tax_amount_usd<br>from analytics.stg_orders</pre><h3>Common Real-World Use Cases</h3><ul><li><strong>Standardizing Column Formats:</strong> Clean strings, format phone numbers, or force column lowercasing across disparate data sources.</li><li><strong>Handling JSON Extraction:</strong> Abstract away complex warehouse-specific JSON parsing syntax (e.g., Snowflake vs. BigQuery vs. Postgres).</li><li><strong>Dynamic Pivot Queries:</strong> Use loops to dynamically unpivot or pivot tall tables into wide analytics tables without hardcoding columns.</li><li><strong>Custom Schema &amp; Grant Management:</strong> Override default dbt behavior for setting database target schemas or table grants.</li></ul><h3>Best Practices for Writing Macros</h3><ul><li><strong>Keep them focused:</strong> A macro should do one task well. Avoid building monolithic macros that handle too many distinct operations.</li><li><strong>Leverage Packages First:</strong> Before building custom code look into community-maintained packages like dbt-utils or dbt-expectations.</li><li><strong>Document Your Macros:</strong> Document macros in a macros.yml schema file or add inline Jinja comments {# comment here #} to help team members understand usage.</li><li><strong>Test via </strong><strong>dbt compile:</strong> Check your rendered code in the target/compiled/ directory to ensure the generated SQL matches expectations.</li></ul><p>By moving repeated logic out of individual models and into centralized macros you dramatically increase readability, simplify maintenance and reduce risk across your entire data pipeline.</p><p>#AnalyticsEngineering #DataEngineering #dbt #SQL #SoftwareEngineering #DataScience</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdd2a44191cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Snowflake Data Spilling: How to Diagnose and Eliminate Local & Remote Disk Spills]]></title>
            <link>https://medium.com/@saideep.uikey2010/demystifying-snowflake-data-spilling-how-to-diagnose-and-eliminate-local-remote-disk-spills-43f3cb00a7bd?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/43f3cb00a7bd</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 18:56:42 GMT</pubDate>
            <atom:updated>2026-07-30T18:56:42.179Z</atom:updated>
            <content:encoded><![CDATA[<p>When optimizing performance and costs in Snowflake, few metrics are as telling or as dreaded as <strong>disk spilling</strong>. If you have ever opened Snowflake’s Query Profile and noticed significant metrics in <em>Bytes Spilled to Local Storage</em> or <em>Bytes Spilled to Remote Storage</em>, you are witnessing a major bottleneck in action.</p><p>Understanding why spilling happens, how it affects your cloud bill and how to fix it is a fundamental skill for data engineers and analytics engineers.</p><h3>What is Data Spilling in Snowflake?</h3><p>To execute SQL operations like JOIN, GROUP BY, ORDER BY or WINDOW functions, a virtual warehouse node allocates RAM to store intermediate result sets.</p><p>When a query’s working dataset exceeds the memory (RAM) allocated to a warehouse node, Snowflake is forced to move intermediate data out of memory. This process is known as <strong>spilling</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U4KFurdoPxxBDwcvy9nZ1A.png" /></figure><p>Snowflake handles spilling in two sequential tiers:</p><pre>+-------------------------------------------------------+<br>|                    1. RAM (Memory)                    |<br>|             Fastest access, limited size             |<br>+-------------------------------------------------------+<br>                           |<br>                           v (RAM exhausted)<br>+-------------------------------------------------------+<br>|                2. Local Storage (SSD)                 |<br>|            Slower than RAM (Local Spilling)           |<br>+-------------------------------------------------------+<br>                           |<br>                           v (Local SSD exhausted)<br>+-------------------------------------------------------+<br>|            3. Remote Storage (S3/GCS/Blob)           |<br>|     Slowest I/O due to Network Latency (Remote Spill) |<br>+-------------------------------------------------------+</pre><h3>1. Local Disk Spilling (Level 1)</h3><ul><li><strong>What happens:</strong> Data overflows from node RAM onto the local SSD drive attached to the virtual machine instance.</li><li><strong>Impact:</strong> Moderate performance penalty. Reading and writing to an SSD involves disk I/O which is significantly slower than direct RAM operations.</li></ul><h3>2. Remote Disk Spilling (Level 2)</h3><ul><li><strong>What happens:</strong> The local SSD storage on the node fills up completely. Snowflake must now write excess intermediate data across the network to cloud object storage (such as AWS S3, Azure Blob or Google Cloud Storage).</li><li><strong>Impact:</strong> <strong>Severe performance degradation</strong>. Network latency and remote I/O overhead can increase query runtimes exponentially, leading to runaway compute credit usage.</li></ul><h3>Identifying Spilling in Your Account</h3><h3>Method 1: Using the Query Profile UI</h3><ul><li>Navigate to <strong>Activity &gt; Query History</strong> in Snowsight.</li><li>Click on the slow-running query and open its <strong>Query Profile</strong>.</li><li>Look at the <strong>Attributes</strong> panel on the left.</li><li>Check the values for <strong>Bytes spilled to local storage</strong> and <strong>Bytes spilled to remote storage</strong>.</li></ul><h3>Method 2: Querying Account Usage Metadata</h3><p>To programmatically scan for the worst spilling queries across your account over the last 30 days, run this query against ACCOUNT_USAGE:</p><pre>SELECT <br>    query_id,<br>    user_name,<br>    warehouse_name,<br>    warehouse_size,<br>    execution_time / 1000 AS execution_time_seconds,<br>    ROUND(bytes_spilled_to_local_storage / (1024 * 1024 * 1024), 2) AS local_spill_gb,<br>    ROUND(bytes_spilled_to_remote_storage / (1024 * 1024 * 1024), 2) AS remote_spill_gb,<br>    SUBSTR(query_text, 1, 100) AS partial_query_text<br>FROM snowflake.account_usage.query_history<br>WHERE start_time &gt;= DATEADD(&#39;day&#39;, -30, CURRENT_TIMESTAMP())<br>  AND (bytes_spilled_to_local_storage &gt; 0 OR bytes_spilled_to_remote_storage &gt; 0)<br>ORDER BY bytes_spilled_to_remote_storage DESC, bytes_spilled_to_local_storage DESC<br>LIMIT 20;</pre><h3>Root Causes &amp; How to Fix Them</h3><h3>1. Unnecessary Column Projections (SELECT *)</h3><ul><li><strong>The Problem:</strong> Including large VARCHAR or VARIANT columns (like JSON blobs) in your SELECT statements forces Snowflake to carry heavy payloads through memory-intensive operations like joins or sorts.</li><li><strong>The Fix:</strong> Select <strong>only</strong> the required columns. If you need metadata or JSON payloads, join them back at the very end of your transform query after filtering and aggregation are complete.</li></ul><h3>2. Early Inefficient Aggregations and Unfiltered Joins</h3><ul><li><strong>The Problem:</strong> Joining two large datasets before applying filters forces Snowflake to hold millions of unnecessary rows in RAM.</li><li><strong>The Fix:</strong> Filter as early as possible in your Common Table Expressions (CTEs). Push down WHERE clauses into CTEs so only relevant micro-partitions are processed.</li></ul><pre>-- ❌ Poor Practice: Filtering after the join<br>WITH raw_data AS (<br>    SELECT * FROM orders JOIN lineitems ON orders.id = lineitems.order_id<br>)<br>SELECT * FROM raw_data WHERE order_date &gt;= &#39;2026-01-01&#39;;<br><br>-- ✅ Optimized Practice: Filter early inside the CTE<br>WITH filtered_orders AS (<br>    SELECT order_id, customer_id, total_price <br>    FROM orders <br>    WHERE order_date &gt;= &#39;2026-01-01&#39;<br>)<br>SELECT fo.order_id, fo.total_price, li.item_id<br>FROM filtered_orders fo<br>JOIN lineitems li ON fo.order_id = li.order_id;</pre><h3>3. Monolithic Single Queries</h3><ul><li><strong>The Problem:</strong> Complex queries with multiple nested window functions, heavy sorts and high-cardinality GROUP BY overload the warehouse memory buffer.</li><li><strong>The Fix:</strong> Break the query into multiple steps using <strong>temporary tables</strong> (CREATE TEMPORARY TABLE ...). This flushes intermediate memory, releases RAM and prevents data spilling across execution steps.</li></ul><h3>4. Undersized Virtual Warehouse</h3><ul><li><strong>The Problem:</strong> When a query is fully optimized but still processes massive data volumes, a small warehouse size (e.g. Small or X-Small) simply lacks the required RAM per node.</li><li><strong>The Fix:</strong> Scale up the virtual warehouse (e.g. from S to M or L). Resizing linearly increases both the available RAM and local SSD storage per node, enabling heavy parallel operations to fit in memory.</li></ul><blockquote><strong><em>Rule of Thumb:</em></strong><em> Always optimize SQL logic </em>first<em>. Only scale up the warehouse if query profiling confirms that pruning is efficient, parallelism is high and memory capacity per node remains the primary bottleneck.</em></blockquote><h3>Conclusion</h3><p>Data spilling is Snowflake’s warning signal that your compute resources and data volume are out of alignment. By catching spills early using system query logs, slimming down query payloads and strategically sizing virtual warehouses you can achieve faster query runtimes and significantly lower monthly Snowflake costs.</p><p>#Snowflake #DataEngineering #CloudComputing #DataOptimization #SQL #DatabaseTuning</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43f3cb00a7bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering SCD Type 2 with dbt Snapshots: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@saideep.uikey2010/mastering-scd-type-2-with-dbt-snapshots-a-step-by-step-guide-a7aa0581b98e?source=rss-cd5174981dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7aa0581b98e</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[Saideep Uikey]]></dc:creator>
            <pubDate>Fri, 24 Jul 2026 02:42:11 GMT</pubDate>
            <atom:updated>2026-07-24T02:42:55.678Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous article <a href="https://medium.com/@saideep.uikey2010/the-data-engineers-guide-to-slowly-changing-dimensions-striking-the-balance-between-cost-and-f226119d0c8f?sharedUserId=saideep.uikey2010">here</a>, we explored the concept of <strong>Slowly Changing Dimensions (SCD)</strong> and evaluated the trade-offs between Type 1 (overwrite), Type 2 (add new row) and Type 3 (add new column).</p><p>While SCD Type 2 is the gold standard for preserving complete historical context, implementing it traditionally required complex MERGE statements, tricky date windowing and custom Change Data Capture (CDC) logic.</p><p>Fortunately, <strong>dbt (data build tool)</strong> makes implementing SCD Type 2 remarkably straightforward using <strong>Snapshots</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Q0TcJFgibCcmlYmukThGw.png" /></figure><h3>What is a dbt Snapshot?</h3><p>A dbt snapshot records changes to a source table over time. When you run dbt snapshot, dbt queries your source table, compares it with the existing snapshot table and:</p><ul><li><strong>Inserts new records</strong> if primary keys don’t exist yet.</li><li><strong>Invalidates old records</strong> (sets dbt_valid_to to the current timestamp) when values change.</li><li><strong>Creates a new active record</strong> (where dbt_valid_to is NULL).</li></ul><p>Under the hood dbt automatically injects metadata columns to manage the record lifecycles:</p><ul><li>dbt_valid_from: Timestamp when the record became active.</li><li>dbt_valid_to: Timestamp when the record was superseded (or NULL if active).</li><li>dbt_scd_id: Unique hash key generated for each historical version of a row.</li><li>dbt_updated_at: The timestamp of the source record update.</li></ul><h3>Step 1: Choosing Your Snapshot Strategy</h3><p>dbt supports two snapshot strategies out of the box:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8VS-wiH0CfX8M3Mg5lbBQ.png" /></figure><h3>Step 2: Creating Your Snapshot File</h3><p>Snapshots live in the snapshots/ directory of your dbt project as .sql files containing a snapshot block and a standard SELECT statement.</p><h4>Example 1: The Timestamp Strategy</h4><pre>{% snapshot dim_users_snapshot %}<br><br>{{<br>    config(<br>      target_schema=&#39;snapshots&#39;,<br>      unique_key=&#39;user_id&#39;,<br>      strategy=&#39;timestamp&#39;,<br>      updated_at=&#39;updated_at&#39;,<br>      invalidate_hard_deletes=True<br>    )<br>}}<br><br>select<br>    user_id,<br>    first_name,<br>    last_name,<br>    email,<br>    plan_tier,<br>    address,<br>    updated_at<br>from {{ source(&#39;raw_data&#39;, &#39;users&#39;) }}<br><br>{% endsnapshot %}</pre><h4>Example 2: The Check Strategy</h4><p>If your source table updates without maintaining an updated_at column, monitor specific columns instead:</p><pre>{% snapshot dim_products_snapshot %}<br><br>{{<br>    config(<br>      target_schema=&#39;snapshots&#39;,<br>      unique_key=&#39;product_id&#39;,<br>      strategy=&#39;check&#39;,<br>      check_cols=[&#39;price&#39;, &#39;category&#39;, &#39;status&#39;]<br>    )<br>}}<br><br>select<br>    product_id,<br>    product_name,<br>    category,<br>    price,<br>    status<br>from {{ source(&#39;raw_data&#39;, &#39;products&#39;) }}<br><br>{% endsnapshot %}</pre><h3>Step 3: Executing and Testing Snapshots</h3><p>To run your snapshots, execute the following CLI command:</p><pre>dbt snapshot</pre><p>On initial execution, dbt builds the snapshot table with all current records assigned dbt_valid_to = NULL. On subsequent runs, dbt inspects for delta changes and updates the target snapshot table accordingly.</p><h4>Adding Quality Tests</h4><p>Treat your snapshots like any other model by adding tests in your schema YAML file:</p><pre>version: 2<br><br>snapshots:<br>  - name: dim_users_snapshot<br>    columns:<br>      - name: dbt_scd_id<br>        tests:<br>          - unique<br>          - not_null<br>      - name: user_id<br>        tests:<br>          - not_null</pre><h3>Step 4: Downstream Consumption in Models</h3><p>Once your snapshot is created, query it in downstream dimensional models just like a regular dbt model using ref():</p><pre>-- models/marts/dim_users.sql<br>select<br>    dbt_scd_id as user_sk, -- Surrogate key for point-in-time joins<br>    user_id,<br>    first_name,<br>    last_name,<br>    email,<br>    plan_tier,<br>    dbt_valid_from as effective_start_date,<br>    coalesce(dbt_valid_to, &#39;9999-12-31&#39;::timestamp) as effective_end_date,<br>    (dbt_valid_to is null) as is_current<br>from {{ ref(&#39;dim_users_snapshot&#39;) }}</pre><h3>Best Practices for dbt Snapshots</h3><ol><li><strong>Keep Snapshot Queries Simple:</strong> Avoid performing heavy transformations, joins, or aggregations inside the snapshot query itself. Snapshot the raw or lightly cleaned source data first then transform downstream.</li><li><strong>Handle Hard Deletes Wisely:</strong> Use invalidate_hard_deletes=True if you want dbt to set dbt_valid_to when a row is completely deleted from the source table.</li><li><strong>Schedule Frequent Runs:</strong> Snapshots only capture state at the exact time dbt snapshot runs. Set your orchestration tool (e.g. dbt Cloud, Airflow) to run snapshots at a frequency matching your reporting granularities.</li></ol><h3>Summary</h3><p>dbt snapshots eliminate the tedious plumbing needed to build historical dimension tables. By defining your primary key and strategy, dbt automates row-level tracking so you can focus on building analytics rather than maintaining CDC logic.</p><p>#DataEngineering #dbt #DataWarehousing #AnalyticsEngineering #SCD #SQL #DataScience</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7aa0581b98e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>