{"id":113570,"date":"2026-12-02T12:00:00","date_gmt":"2026-12-02T12:00:00","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=113570"},"modified":"2026-11-11T13:49:22","modified_gmt":"2026-11-11T13:49:22","slug":"dbt-incremental-load-fact-table-microsoft-fabric","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/data-analytics\/dbt-incremental-load-fact-table-microsoft-fabric\/","title":{"rendered":"How to incrementally load a fact table with dbt in Microsoft Fabric"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>TL;DR:<\/strong> <strong>An incremental load in dbt processes only new or changed rows instead of rebuilding the whole table. To load a fact table incrementally in Microsoft Fabric, set the model\u2019s materialization to <code>incremental<\/code>, filter with the <code>is_incremental()<\/code> macro, and define a unique key and the delete+insert strategy to avoid duplicates.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide starts with a simple full load (the <strong>truncate-and-load pattern<\/strong>) using the <code>AdventureWorksLT<\/code> sales data, then converts it to an incremental model and tests it in the dbt debug logs. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Previously, I&#8217;ve covered how to create <a href=\"https:\/\/www.red-gate.com\/simple-talk\/business-intelligence\/general-analytics\/a-gentle-introduction-to-dbt\/\" target=\"_blank\" rel=\"noreferrer noopener\">type 2 slowly changing dimensions<\/a>, how to <a href=\"https:\/\/www.red-gate.com\/simple-talk\/data-analytics\/general-analytics\/how-to-script-dimensions-with-data-build-tool-dbt-macros\/\" target=\"_blank\" rel=\"noreferrer noopener\">load regular dimensions with macros<\/a>, and how to <a href=\"https:\/\/www.red-gate.com\/simple-talk\/data-analytics\/general-analytics\/how-to-load-a-date-dimension-in-microsoft-fabric-using-macros-in-dbt\/\" target=\"_blank\" rel=\"noreferrer noopener\">create a date dimension<\/a>. The code runs in <a href=\"https:\/\/www.getdbt.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">dbt Cloud<\/a> against a <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/choosing-between-the-lakehouse-and-warehouse-in-microsoft-fabric\/\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Fabric Warehouse<\/a>.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-load-a-fact-table-with-dbt\">How to load a fact table with dbt<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First, I&#8217;ll explain how to load a fact table with dbt. There are various methods for achieving this.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-full-load-the-truncate-and-load-pattern-in-dbt\">Full load: the truncate-and-load pattern in dbt<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The simplest way of loading a fact table is either dropping the table or truncating it<\/strong>, and then loading all data from scratch. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It may not be the most efficient way to load data, but development time is short, there\u2019s not much that can go wrong (when compared with incremental loading techniques), and modern data warehouses can process millions of rows with ease.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>In dbt, when you materialize a model as a table and don\u2019t specify any loading technique, the default is a full reload.<\/strong> dbt drops the existing table and creates a new one with a <code>CREATE TABLE AS SELECT<\/code> statement, so it\u2019s technically drop-and-recreate rather than <code>TRUNCATE<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In reality, a lot more happens than that. To see exactly how dbt loads data, you can always open the debug logs:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"793\" height=\"403\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image.jpg\" alt=\"An image showing the dbt debug logs.\" class=\"wp-image-113571\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image.jpg 793w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-300x152.jpg 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-768x390.jpg 768w\" sizes=\"auto, (max-width: 793px) 100vw, 793px\" \/><figcaption class=\"wp-element-caption\"><em>The debug logs in dbt.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thus, to load a fact table from scratch, we need to define a model that contains the business logic (any calculations for measures and lookups to the relevant dimensions). <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Helpfully, I&#8217;ve already written one, as shown in my <a href=\"https:\/\/www.red-gate.com\/simple-talk\/data-analytics\/general-analytics\/loading-models-from-source-data-with-dbt\/\" target=\"_blank\" rel=\"noreferrer noopener\">Loading Models from Source Data with dbt<\/a> guide:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">WITH cte_details AS\n(\n    SELECT\n         SalesOrderID\n        ,SalesOrderDetailID\n        ,OrderQty\n        ,ProductID\n        ,UnitPrice\n        ,UnitPriceDiscount\n        ,LineTotal = \n            ISNULL(OrderQty * (1.0 - ISNULL(UnitPriceDiscount,0.0)) * UnitPrice,0.0)\n    FROM {{ source('adventureworkslt', 'SalesOrderDetail') }}\n), cte_sales AS\n(\n    SELECT\n         soh.SalesOrderID\n        ,sod.SalesOrderDetailID\n        ,SK_OrderDate   = CONVERT(DATE,soh.OrderDate)\n        ,SK_DueDate     = CONVERT(DATE,soh.DueDate)\n        ,SK_ShipDate    = CONVERT(DATE,soh.ShipDate)\n        ,soh.PurchaseOrderNumber\n        ,soh.AccountNumber\n        ,soh.CustomerID\n        ,sod.ProductID\n        ,sod.OrderQty\n        ,sod.UnitPrice\n        ,sod.UnitPriceDiscount\n        ,sod.LineTotal\n        \/* the next two costs are evenly divided over the detail lines *\/\n        ,TaxAmt         = soh.TaxAmt \/ (COUNT(1) OVER (PARTITION BY soh.SalesOrderID))\n        ,Freight        = soh.Freight \/ (COUNT(1) OVER (PARTITION BY soh.SalesOrderID))\n    FROM {{ source('adventureworkslt', 'SalesOrderHeader') }}   soh\n    JOIN cte_details                sod ON soh.SalesOrderID = sod.SalesOrderID\n)\nSELECT\n     SalesOrderID\n    ,SalesOrderDetailID\n    ,SK_OrderDate\n    ,SK_DueDate\n    ,SK_ShipDate\n    ,PurchaseOrderNumber\n    ,AccountNumber\n    ,CustomerID\n    ,ProductID\n    ,OrderQty\n    ,UnitPrice\n    ,UnitPriceDiscount\n    ,LineTotal\n    ,TaxAmt\n    ,Freight\n    ,TotalAmount  = LineTotal + ISNULL(TaxAmt,0.0) + ISNULL(Freight,0.0)\nFROM cte_sales;<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Since we\u2019ve created a customer and product dimension by now, we need to retrieve their respective <strong><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/the-secret-life-of-database-keys\/#:~:text=a%20surrogate%20key%20(sometimes%20called%20a%20synthetic%20key)%20is%20a%20value%20added%20to%20each%20row%20upon%20creation.%20A%20surrogate%20exists%20only%20within%20the%20confines%20of%20the%20database%3B%20it%20has%20no%20meaning%20outside%20of%20it.\" target=\"_blank\" rel=\"noreferrer noopener\">surrogate keys<\/a><\/strong>. There are two ways of achieving this.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-lookup-method-join-to-the-dimension-for-surrogate-keys\">The lookup method: join to the dimension for surrogate keys<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-the-lookup-methodwe-can-do-a-lookup-on-the-actual-dimension-with-a-left-outer-join-on-the-business-key-and-fetch-the-surrogate-key-sk-the-advantage-here-is-that-we-can-check-for-referential-integrity-if-the-sk-isn-t-found-we-can-replace-it-with-a-dummy-value-like-1-for-example-or-maybe-even-throw-an-error\">We can do a lookup on the actual dimension with a <code>LEFT OUTER JOIN<\/code> on the business key and fetch the surrogate key (SK). The advantage here is that we can check for referential integrity. If the SK isn\u2019t found, we can replace it with a dummy value (like -1, for example), or maybe even throw an error.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-hash-method-generate-surrogate-keys-without-a-join\">The hash method: generate surrogate keys without a join<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-the-lookup-methodwe-can-do-a-lookup-on-the-actual-dimension-with-a-left-outer-join-on-the-business-key-and-fetch-the-surrogate-key-sk-the-advantage-here-is-that-we-can-check-for-referential-integrity-if-the-sk-isn-t-found-we-can-replace-it-with-a-dummy-value-like-1-for-example-or-maybe-even-throw-an-error\">Alternatively, we can <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hash_function\" target=\"_blank\" rel=\"noreferrer noopener\">hash<\/a> the business key of the dimension (<code>ProductID<\/code>, for example) by using the same method we used to create the surrogate keys of the dimension. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-the-lookup-methodwe-can-do-a-lookup-on-the-actual-dimension-with-a-left-outer-join-on-the-business-key-and-fetch-the-surrogate-key-sk-the-advantage-here-is-that-we-can-check-for-referential-integrity-if-the-sk-isn-t-found-we-can-replace-it-with-a-dummy-value-like-1-for-example-or-maybe-even-throw-an-error\">This has the advantage of <em>not<\/em> needing the <code>LEFT OUTER JOIN<\/code>, and we can load the fact table in parallel with the dimensions. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-the-lookup-methodwe-can-do-a-lookup-on-the-actual-dimension-with-a-left-outer-join-on-the-business-key-and-fetch-the-surrogate-key-sk-the-advantage-here-is-that-we-can-check-for-referential-integrity-if-the-sk-isn-t-found-we-can-replace-it-with-a-dummy-value-like-1-for-example-or-maybe-even-throw-an-error\">However, there\u2019s no check on <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/theory-and-design\/constraints-and-declarative-referential-integrity\/\" target=\"_blank\" rel=\"noreferrer noopener\">referential integrity<\/a>, and there\u2019s no lineage that dbt can use.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s alter the script to use the first option &#8211; the <strong>lookup method<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">\u2026\nSELECT\n     f.SalesOrderID\n    ,f.SalesOrderDetailID\n    ,f.SK_OrderDate\n    ,f.SK_DueDate\n    ,f.SK_ShipDate\n    -- the following 2 lines were added\n    -- the original columns are removed\n    ,SK_Customer = ISNULL(c.SK_Customer,'-1')\n    ,SK_Product  = ISNULL(p.SK_Product,'-1')\n    ,f.PurchaseOrderNumber\n    ,f.AccountNumber\n    ,f.ProductID\n    ,f.OrderQty\n    ,f.UnitPrice\n    ,f.UnitPriceDiscount\n    ,f.LineTotal\n    ,f.TaxAmt\n    ,f.Freight\n    ,TotalAmount  = f.LineTotal + ISNULL(f.TaxAmt,0.0) + ISNULL(f.Freight,0.0)\nFROM cte_sales f\n-- the following 2 joins were added\nLEFT JOIN {{ ref('DimProduct') }} p ON f.ProductID = p.ProductID\nLEFT JOIN {{ ref('DimCustomer') }} c ON f.CustomerID = c.CustomerID\n    AND f.SK_OrderDate BETWEEN c.ValidFrom and c.ValidTo<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"940\" height=\"303\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image.png\" alt=\"Image showing the script run with the lookup method.\" class=\"wp-image-113572\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image.png 940w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-300x97.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-768x248.png 768w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><figcaption class=\"wp-element-caption\"><em>The lookup method.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every time we run the model in dbt, the <code>FactSales<\/code> table will be emptied, and all the data from the source tables will be loaded into the fact table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-load-a-fact-table-incrementally-in-dbt-in-brief\">How to load a fact table incrementally in dbt (in brief)<\/h2>\n\n\n<div class=\"block-core-list\">\n<ol class=\"wp-block-list\">\n<li>Convert the full-load model to a view (for example, <code>vw_FactSales<\/code>) and add an <code>UpdateDate<\/code> column to simulate changing data.<br><br><\/li>\n\n\n\n<li>Create a new model, <code>FactSales<\/code>, that selects every column from the view and sets <code>materialized = 'incremental'<\/code>.<br><br><\/li>\n\n\n\n<li>Add an <code>{% if is_incremental() %}<\/code> block that filters on <code>UpdateDate<\/code> greater than the maximum value already in <code>{{ this }}<\/code>.<br><br><\/li>\n\n\n\n<li>Set <code>unique_key<\/code> to <code>['SalesOrderID','SalesOrderDetailID']<\/code> and <code>incremental_strategy<\/code> to <code>'delete+insert'<\/code>.<br><br><\/li>\n\n\n\n<li>Run the model twice and check the row counts and debug logs to confirm no duplicates.<\/li>\n<\/ol>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-load-a-fact-table-incrementally-in-dbt-in-more-detail\">How to load a fact table incrementally in dbt (in more detail)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Loading all the data every time we run the dbt model might <em>not<\/em> be the most efficient way to deal with compute resources, especially in <a href=\"https:\/\/www.red-gate.com\/simple-talk\/cloud\/\" target=\"_blank\" rel=\"noreferrer noopener\">cloud<\/a> environments, for example, where we\u2019re billed by the compute resources spent. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the fact table becomes too large, or if it takes too long to run the model, we\u2019ll want to change to an <strong>incremental load<\/strong>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When loading incrementally, we only deal with data that has been changed, added or deleted since the last time we\u2019ve run the <a href=\"https:\/\/aws.amazon.com\/what-is\/etl\/\" target=\"_blank\" rel=\"noreferrer noopener\">ETL (extract, transform, load)<\/a>. This is much more efficient but takes more development time, and may be harder to debug if something goes wrong.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In dbt, we can configure a model to be loaded incrementally by using the <a href=\"https:\/\/docs.getdbt.com\/docs\/build\/incremental-models?version=2\" target=\"_blank\" rel=\"noreferrer noopener\">incremental<\/a> materialization:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">{{\n&nbsp; config(\n&nbsp; &nbsp; materialized = 'incremental'\n&nbsp; &nbsp; )\n}}<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">When we want to load an incremental table, there are two options.<\/p>\n\n\n\n<section id=\"my-first-block-block_68d0c9d5fd0b61e7cd5a8fc10f60ee55\" class=\"my-first-block alignwide\">\n    <div class=\"bg-brand-600 text-base-white py-5xl px-4xl rounded-sm bg-gradient-to-r from-brand-600 to-brand-500 red\">\n        <div class=\"gap-4xl items-start md:items-center flex flex-col md:flex-row justify-between\">\n            <div class=\"flex-1 col-span-10 lg:col-span-7\">\n                <h3 class=\"mt-0 font-display mb-2 text-display-sm\">Subscribe to the Simple Talk newsletter<\/h3>\n                <div class=\"child:last-of-type:mb-0\">\n                                            All the latest articles, guides, podcasts, and more &#8211; delivered straight to your inbox.                                    <\/div>\n            <\/div>\n                                            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/subscribe\/\" class=\"btn btn--secondary btn--lg\" aria-label=\"Subscribe now: Subscribe to the Simple Talk newsletter\">Subscribe now<\/a>\n                    <\/div>\n    <\/div>\n<\/section>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-initial-full-load-vs-incremental-load\">Initial (full) load vs incremental load<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-initial-loadan-initial-load-a-full-load-where-all-the-data-that-we-currently-have-is-copied-into-the-table-ideally-we-only-need-to-do-this-one-time-when-the-table-is-loaded-for-the-first-time-however-we-might-want-to-occasionally-do-a-full-load-if-we-have-all-the-source-data-available-for-example-the-column-that-detects-changes-cannot-be-100-trusted-so-on-weekends-we-load-all-data-to-make-sure-all-data-has-been-transferred-or-something-went-wrong-with-the-etl-data-is-missing-and-we-want-to-transfer-all-data-again-to-start-fresh-again\"><strong>An initial load is a full load where all the data that we currently have is copied into the table.<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-initial-loadan-initial-load-a-full-load-where-all-the-data-that-we-currently-have-is-copied-into-the-table-ideally-we-only-need-to-do-this-one-time-when-the-table-is-loaded-for-the-first-time-however-we-might-want-to-occasionally-do-a-full-load-if-we-have-all-the-source-data-available-for-example-the-column-that-detects-changes-cannot-be-100-trusted-so-on-weekends-we-load-all-data-to-make-sure-all-data-has-been-transferred-or-something-went-wrong-with-the-etl-data-is-missing-and-we-want-to-transfer-all-data-again-to-start-fresh-again\">Ideally, we only need to do this <em>once<\/em> (when the table is loaded for the first time), but we might want to occasionally do a full load if we have all the source data available. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-initial-loadan-initial-load-a-full-load-where-all-the-data-that-we-currently-have-is-copied-into-the-table-ideally-we-only-need-to-do-this-one-time-when-the-table-is-loaded-for-the-first-time-however-we-might-want-to-occasionally-do-a-full-load-if-we-have-all-the-source-data-available-for-example-the-column-that-detects-changes-cannot-be-100-trusted-so-on-weekends-we-load-all-data-to-make-sure-all-data-has-been-transferred-or-something-went-wrong-with-the-etl-data-is-missing-and-we-want-to-transfer-all-data-again-to-start-fresh-again\">For example, the column that detects changes cannot be 100% trusted, so on weekends we may want to load all the data to make sure it has all been transferred correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-initial-loadan-initial-load-a-full-load-where-all-the-data-that-we-currently-have-is-copied-into-the-table-ideally-we-only-need-to-do-this-one-time-when-the-table-is-loaded-for-the-first-time-however-we-might-want-to-occasionally-do-a-full-load-if-we-have-all-the-source-data-available-for-example-the-column-that-detects-changes-cannot-be-100-trusted-so-on-weekends-we-load-all-data-to-make-sure-all-data-has-been-transferred-or-something-went-wrong-with-the-etl-data-is-missing-and-we-want-to-transfer-all-data-again-to-start-fresh-again\">Or, maybe something went wrong with the ETL, data is missing, and we want to transfer all data again to start &#8216;fresh&#8217;.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-how-to-force-a-full-load-of-an-incremental-model\">How to force a full load of an incremental model<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">To force a full load of an incremental model, run it with the <code>--full-refresh<\/code> flag (for example, <code>dbt run --full-refresh --select FactSales<\/code>) or set <code>full_refresh = true<\/code> in the model config. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">dbt then rebuilds the table from scratch, and <code>is_incremental()<\/code> returns false for that run.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-how-to-filter-new-rows-with-the-is-incremental-macro\">How to filter new rows with the <code>is_incremental()<\/code> macro<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-incremental-loadan-incremental-load-where-only-changes-since-the-last-etl-run-are-transferred-or-a-moving-fixed-interval-is-loaded-for-example-we-load-all-data-from-the-last-3-days\"><strong>An incremental load transfers <em>only<\/em> the changes since the last ETL run, or loads a moving fixed window of data (for example, everything from the last three days).<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This means we need to <em>optionally<\/em> add a <code>WHERE<\/code> clause to our model. No filters are required when doing a full load but, when loading incrementally, we must filter on one (or more) columns to determine the change set. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is where the <a href=\"https:\/\/docs.getdbt.com\/docs\/build\/incremental-models?version=2#understand-the-is_incremental-macro\" target=\"_blank\" rel=\"noreferrer noopener\"><code>is_incremental()<\/code><\/a> macro comes into play. With this macro, we can dynamically add logic to our model that will handle the incremental loading. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s illustrate this with our <code>FactSales<\/code> model.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-step-by-step-guide\">Step-by-step guide<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">First, we convert the existing model to a view, and then rename the model to <code>vw_FactSales.sql<\/code> &#8211; just like we did with the product and customer dimensions:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"310\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-1.png\" alt=\"An image showing the renaming of the model.\" class=\"wp-image-113573\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-1.png 801w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-1-300x116.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-1-768x297.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><figcaption class=\"wp-element-caption\"><em>Renaming the model.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At the end of the view, we add an <code>UpdateDate<\/code> column using <code>GETDATE()<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"930\" height=\"149\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-2.png\" alt=\"an image showing the addition of an UpdateDate column using GETDATE().\" class=\"wp-image-113574\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-2.png 930w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-2-300x48.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-2-768x123.png 768w\" sizes=\"auto, (max-width: 930px) 100vw, 930px\" \/><figcaption class=\"wp-element-caption\"><em>Adding an UpdateDate column.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every time data is selected from the view, this column will change values so we can &#8216;mock&#8217; that data has changed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we add a new model and name it <code>FactSales.sql<\/code>. This model will hold our incremental loading strategy and will select <em>every<\/em> column from the view:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">{{\n  config(\n    materialized = 'incremental'\n    )\n}}\nSELECT\n     SalesOrderID\n    ,SalesOrderDetailID\n    ,SK_OrderDate\n    ,SK_DueDate\n    ,SK_ShipDate\n    ,SK_Customer\n    ,SK_Product\n    ,PurchaseOrderNumber\n    ,AccountNumber\n    ,ProductID\n    ,OrderQty\n    ,UnitPrice\n    ,UnitPriceDiscount\n    ,LineTotal\n    ,TaxAmt\n    ,Freight\n    ,TotalAmount\n    ,UpdateDate\nFROM dbo.vw_FactSales<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we can add the <code>is_incremental()<\/code> macro to this model:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">\u2026\nFROM dbo.vw_FactSales\n{% if is_incremental() %}\nWHERE UpdateDate &gt; (SELECT ISNULL(MAX(UpdateDate),'1900-01-01') FROM {{ this }})\n{% endif %}<\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-what-happens-if-is-incremental-returns-true\">What happens if <code>is_incremental()<\/code> returns true<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>If <code>is_incremental()<\/code> returns true, the <code>WHERE<\/code> clause will be added to the model, and only the most recent data since the last ETL run will be added.<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>{{ this }}<\/code> object refers to the current model &#8211; in other words, the <code>FactSales<\/code> table.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using <a href=\"https:\/\/docs.getdbt.com\/reference\/dbt-jinja-functions\/this?version=2\" target=\"_blank\" rel=\"noreferrer noopener\">this<\/a> allows us to query the model we\u2019re loading, so we can use this to find the maximum <code>UpdateDate<\/code>. Only more recent data should be loaded into the model.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-what-happens-if-is-incremental-returns-false\">What happens if <code>is_incremental()<\/code> returns false<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>If <code>is_incremental()<\/code> returns false, nothing is added to the <code>SELECT<\/code> statement, and all data from the view will be loaded into the fact table.<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This function will return true if:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li><strong>The<\/strong> <strong>model is configured as incremental<\/strong><\/li>\n\n\n\n<li><strong>The<\/strong> <strong>table already exists in the database<\/strong> (if it doesn\u2019t, we will do an initial load)<\/li>\n\n\n\n<li><strong>There\u2019s no &#8220;full&#8221; load set<\/strong> (which can be done as a <a href=\"https:\/\/docs.getdbt.com\/reference\/resource-configs\/full_refresh?version=2\" target=\"_blank\" rel=\"noreferrer noopener\">config<\/a> or as a <a href=\"https:\/\/docs.getdbt.com\/docs\/build\/incremental-models?version=2#how-do-i-rebuild-an-incremental-model\" target=\"_blank\" rel=\"noreferrer noopener\">command<\/a>).<\/li>\n<\/ul>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">When we compile our model, note that there\u2019s no <code>WHERE<\/code> clause added. This is because the table doesn\u2019t yet exist in the Fabric warehouse:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"341\" height=\"565\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-3.png\" alt=\"an image showing that the table doesn't yet exist in the fabric warehouse, hence there's no visible WHERE clause.\" class=\"wp-image-113578\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-3.png 341w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-3-181x300.png 181w\" sizes=\"auto, (max-width: 341px) 100vw, 341px\" \/><figcaption class=\"wp-element-caption\"><em>The table doesn&#8217;t yet exist in the Fabric warehouse, so there&#8217;s no <code>WHERE<\/code> clause&#8230;<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When we run the models for the view <em>and<\/em> the fact table, then compile again, the <code>WHERE<\/code> clause is added:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"940\" height=\"462\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-4.png\" alt=\"an image showing that the WHERE clause has now been added\" class=\"wp-image-113579\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-4.png 940w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-4-300x147.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-4-768x377.png 768w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><figcaption class=\"wp-element-caption\"><em>The <code>WHERE<\/code> clause is now visible.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If we run the model again, all data will be loaded into the fact table for a second time, since the <code>UpdateDate<\/code> column now has a more recent value:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"471\" height=\"208\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-5.png\" alt=\"an image showing that the UpdateDate column now has a more recent value.\" class=\"wp-image-113580\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-5.png 471w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-5-300x132.png 300w\" sizes=\"auto, (max-width: 471px) 100vw, 471px\" \/><figcaption class=\"wp-element-caption\"><em>The <code>UpdateDate<\/code> column now has a more recent value.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, what if the data contains both inserts <em>and<\/em> updates? Or, what if we load the <em>same data<\/em> in an ETL that runs later on? And how do we handle this to <strong>avoid duplicates<\/strong> in our fact table?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-dbt-incremental-strategies-append-delete-insert-merge-and-more\">dbt incremental strategies: append, delete+insert, merge, and more<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The key to loading an incremental table correctly is to specify a unique key and an incremental strategy.<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Depending on the strategy used, dbt can use the unique key to determine if an incoming row should be used for an update or an insert. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The following strategies are available:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-append-strategy\">The append strategy <\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">With the <strong><a href=\"https:\/\/docs.getdbt.com\/docs\/build\/incremental-strategy?version=2#append\" target=\"_blank\" rel=\"noreferrer noopener\">append<\/a><\/strong> strategy, data returned by the <code>SELECT<\/code> statement of the model is inserted &#8216;as-is&#8217; into the model <em>without<\/em> checks. If no unique key is specified, this is the default behavior. It explains why we ended up with 1,084 rows in the fact table: the 542 source rows were loaded twice.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This strategy might be useful when your fact table is insert-only and you have a solid method of detecting new rows in your source (event stream data, for example).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-delete-insert-strategy\">The delete+insert strategy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-the-delete-insert-strategyif-the-unique-key-gives-a-match-the-row-is-deleted-from-the-target-table-and-the-row-from-the-source-is-inserted-you-can-use-this-method-if-you-use-a-moving-batch-window-e-g-all-data-from-the-last-3-days-if-data-already-exists-it-s-deleted-and-re-inserted\">If the <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/theory-and-design\/uniqueness-keys-and-identity\/\" target=\"_blank\" rel=\"noreferrer noopener\">unique key<\/a> gives a match, the row is deleted from the target table and the row from the source is inserted instead. You can use the <strong>delete+insert<\/strong> if you use a moving batch window (e.g. all data from the last 3 days).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-the-delete-insert-strategyif-the-unique-key-gives-a-match-the-row-is-deleted-from-the-target-table-and-the-row-from-the-source-is-inserted-you-can-use-this-method-if-you-use-a-moving-batch-window-e-g-all-data-from-the-last-3-days-if-data-already-exists-it-s-deleted-and-re-inserted\">If data already exists, however, it\u2019s simply deleted and re-inserted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-merge-strategy\">The merge strategy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-the-merge-strategy-an-incoming-row-doesn-t-exist-it-is-inserted-if-the-unique-key-gives-a-match-the-target-row-will-be-updated-if-a-unique-key-is-not-specified-merge-reverts-to-append\">The <strong>merge <\/strong>strategy ensures that, if an incoming row doesn\u2019t exist, it is inserted. Additionally, if the unique key gives a match, the target row will be updated. And finally, if a unique key is <em>not<\/em> specified, the merge reverts to append.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-insert-overwrite-strategy\">The <code>insert_overwrite<\/code> strategy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code><strong>insert_overwrite<\/strong><\/code><strong> <\/strong>can be used on <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/oracle-databases\/introduction-to-table-partitioning\/\" target=\"_blank\" rel=\"noreferrer noopener\">partitioned tables<\/a>, where an entire partition is overwritten if it already exists. If the partition does <em>not<\/em> currently exist, however, data is written to a new partition.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-microbatch-strategy\">The microbatch strategy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/docs.getdbt.com\/docs\/build\/incremental-microbatch?version=2\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>microbatch<\/strong><\/a> strategy is used for processing large <a href=\"https:\/\/db-engines.com\/en\/article\/Time+Series+DBMS\" target=\"_blank\" rel=\"noreferrer noopener\">time-series<\/a> datasets. It supports <a href=\"https:\/\/docs.getdbt.com\/docs\/build\/parallel-batch-execution?version=2\" target=\"_blank\" rel=\"noreferrer noopener\">parallel batch execution<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-which-incremental-strategies-does-dbt-support-in-microsoft-fabric\">Which incremental strategies does dbt support in Microsoft Fabric?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s very important to understand that <a href=\"https:\/\/docs.getdbt.com\/docs\/build\/incremental-strategy?version=2#supported-incremental-strategies-by-adapter\" target=\"_blank\" rel=\"noreferrer noopener\">not every database adapter supports all strategies<\/a>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For our case, <strong><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/what-is-microsoft-fabric-all-about\/\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Fabric<\/a> supports <em>append<\/em>, <em>merge<\/em>, <em>delete+insert<\/em>, and <em>microbatch<\/em>.<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Among them, <strong>delete+insert seems the most logical choice for our case<\/strong>, given we don&#8217;t need to update fact rows.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The columns <code>SalesOrderID<\/code> and <code>SalesOrderDetailID<\/code> uniquely define a row. The config of the model becomes:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">{{\n  config(\n    materialized = 'incremental',\n    unique_key = ['SalesOrderID','SalesOrderDetailID'],\n    incremental_strategy = 'delete+insert'\n    )\n}}<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-dbt-incremental-strategies-in-summary-comparison-guide\">The dbt incremental strategies in summary (comparison guide)<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Strategy<\/th><th>When the unique key matches<\/th><th>Best for<\/th><th>Supported in Fabric?<\/th><\/tr><\/thead><tbody><tr><td><strong>append<\/strong><\/td><td>Nothing is checked; rows are inserted as-is (the default without a unique key)<\/td><td>Insert-only data with reliable new-row detection, such as event streams<\/td><td>Yes<\/td><\/tr><tr><td><strong>delete+insert<\/strong><\/td><td>The matching target row is deleted and the source row inserted<\/td><td>Moving batch windows; fact tables that don\u2019t need updates<\/td><td>Yes<\/td><\/tr><tr><td><strong>merge<\/strong><\/td><td>The target row is updated; new rows are inserted<\/td><td>Sources with both inserts and updates<\/td><td>Yes<\/td><\/tr><tr><td><strong><code>insert_overwrite<\/code><\/strong><\/td><td>The whole partition is overwritten<\/td><td>Partitioned tables<\/td><td>No<\/td><\/tr><tr><td><strong>microbatch<\/strong><\/td><td>Not applicable; data is processed in time-based batches, in parallel<\/td><td>Very large time-series datasets<\/td><td>Yes <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-test-the-incremental-model-check-for-duplicates-in-the-logs\">How to test the incremental model (check for duplicates in the logs)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First, let\u2019s drop the table again so we can start fresh. The first time we run the model, 542 rows will be inserted into the fact table. Then, when run a second time, dbt will use the unique key to determine if a row already exists or not. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since all rows already exist, 542 rows will be deleted, and the same data will be inserted again.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"423\" height=\"203\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-6.png\" alt=\"an image showing 542 rows being deleted.\" class=\"wp-image-113583\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-6.png 423w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-6-300x144.png 300w\" sizes=\"auto, (max-width: 423px) 100vw, 423px\" \/><figcaption class=\"wp-element-caption\"><em>542 rows are deleted&#8230;<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When we dive into the debug logs, we can find the <code>DELETE<\/code> statement run by the incremental strategy:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"940\" height=\"318\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-7.png\" alt=\"an image showing the DELETE statement run by the incremental strategy.\" class=\"wp-image-113584\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-7.png 940w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-7-300x101.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-7-768x260.png 768w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><figcaption class=\"wp-element-caption\"><em>The <code>DELETE<\/code> statement run by the incremental strategy.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After the <code>DELETE<\/code>, <code>INSERT<\/code>, and <code>SELECT<\/code> statements are executed:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"940\" height=\"146\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-8.png\" alt=\"Image showing the result of after the DELETE, INSERT, and SELECT statements are executed.\" class=\"wp-image-113585\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-8.png 940w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-8-300x47.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-8-768x119.png 768w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><figcaption class=\"wp-element-caption\"><em>After the <code>DELETE<\/code>, <code>INSERT<\/code>, and <code>SELECT<\/code> statements are executed<\/em>.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Both statements ensure we don\u2019t end up with duplicate rows in our fact table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion-when-to-use-incremental-loads-in-dbt\">Conclusion: when to use incremental loads in dbt<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Incremental loading lets dbt update a fact table with only new or changed rows instead of rebuilding it every run. <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we started with a full load, then converted the model to <code>materialized = 'incremental'<\/code>, filtered with <code>is_incremental()<\/code>, and set a unique key with the delete+insert strategy so reruns don\u2019t create duplicates. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The changes to the model were small; dbt does the heavy lifting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Incremental materialization also works for other table types. Delete+insert, for example, suits an incremental SCD Type 1 dimension. For more advanced options, see the <a href=\"https:\/\/docs.getdbt.com\/docs\/build\/incremental-models?version=2\" target=\"_blank\" rel=\"noreferrer noopener\">dbt incremental models documentation<\/a>.<\/p>\n\n\n\n<section id=\"my-first-block-block_8dca916e3fd910e5cf782c612061bfc6\" class=\"my-first-block alignwide\">\n    <div class=\"bg-brand-600 text-base-white py-5xl px-4xl rounded-sm bg-gradient-to-r from-brand-600 to-brand-500 red\">\n        <div class=\"gap-4xl items-start md:items-center flex flex-col md:flex-row justify-between\">\n            <div class=\"flex-1 col-span-10 lg:col-span-7\">\n                <h3 class=\"mt-0 font-display mb-2 text-display-sm\">Simple Talk is brought to you by Redgate Software<\/h3>\n                <div class=\"child:last-of-type:mb-0\">\n                                            Take control of your databases with the trusted Database DevOps solutions provider. Automate with confidence, scale securely, and unlock growth through AI.                                    <\/div>\n            <\/div>\n                                            <a href=\"https:\/\/www.red-gate.com\/solutions\/overview\/\" class=\"btn btn--secondary btn--lg\" aria-label=\"Discover how Redgate can help you: Simple Talk is brought to you by Redgate Software\">Discover how Redgate can help you<\/a>\n                    <\/div>\n    <\/div>\n<\/section>\n\n\n<section id=\"faq\" class=\"faq-block my-5xl\">\n    <h2>FAQs<\/h2>\n\n            <h3 class=\"mt-4xl\">1. What is an incremental model in dbt?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">An incremental model is built in full on its first run, then updated with only new or changed rows on later runs. You enable it with <code dir=\"ltr\">materialized = 'incremental'<\/code> and filter the source data with the <code dir=\"ltr\">is_incremental()<\/code> macro. This reduces compute time and cost on large tables.<\/p>\n        <\/div>\n            <h3 class=\"mt-4xl\">2. What does is_incremental() do in dbt?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\"><code dir=\"ltr\">is_incremental()<\/code> returns true when the model is configured as incremental, the target table already exists, and no full refresh has been requested. When it\u2019s true, dbt adds the code inside the <code dir=\"ltr\">{% if is_incremental() %}<\/code> block, typically a WHERE filter on a timestamp, so only recent data is loaded.<\/p>\n        <\/div>\n            <h3 class=\"mt-4xl\">3. Which incremental strategies does dbt support in Microsoft Fabric?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">The dbt Fabric adapter supports append, merge, delete+insert and microbatch. For insert-only fact tables, delete+insert is usually the best fit. dbt uses the unique key to delete matching rows, then inserts the incoming rows, so no duplicates are created.<\/p>\n        <\/div>\n            <h3 class=\"mt-4xl\">4. Why does my dbt incremental model create duplicate rows?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">Duplicates usually appear because no <code dir=\"ltr\">unique_key<\/code> is set, so dbt defaults to the append strategy and inserts every row it selects. Define a unique key (for a sales fact, <code>SalesOrderID<\/code> and <code>SalesOrderDetailID<\/code>) and use delete+insert or merge so existing rows are replaced, not repeated.<\/p>\n        <\/div>\n            <h3 class=\"mt-4xl\">5. How do I force a full reload of an incremental model?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">Run the model with the <code dir=\"ltr\">--full-refresh<\/code> flag, for example <code dir=\"ltr\">dbt run --full-refresh --select FactSales<\/code>, or set <code dir=\"ltr\">full_refresh = true<\/code> in the model config. dbt then rebuilds the table from scratch, and <code dir=\"ltr\">is_incremental()<\/code> returns false for that run.<\/p>\n<p dir=\"ltr\">The last answer depends on the article naming <code dir=\"ltr\">--full-refresh<\/code>, which it doesn\u2019t do yet. Add one sentence to the \u201cInitial load\u201d section so the FAQ is backed by the body.<\/p>\n        <\/div>\n    <\/section>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to load a fact table incrementally with dbt in Microsoft Fabric, using is_incremental(), a unique key and the delete+insert strategy.&hellip;<\/p>\n","protected":false},"author":110905,"featured_media":107188,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[159160,53,159165,159164],"tags":[159230,158997],"coauthors":[159081],"class_list":["post-113570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-analytics","category-featured","category-general-analytics","category-microsoft-fabric","tag-dbt","tag-microsoft-fabric"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/113570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/110905"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=113570"}],"version-history":[{"count":7,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/113570\/revisions"}],"predecessor-version":[{"id":113899,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/113570\/revisions\/113899"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media\/107188"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=113570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=113570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=113570"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=113570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}