<?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 Ashiq Sultan on Medium]]></title>
        <description><![CDATA[Stories by Ashiq Sultan on Medium]]></description>
        <link>https://medium.com/@ashiq.sultan?source=rss-eab977776e31------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*nGr6bF2B5FFDt3_i</url>
            <title>Stories by Ashiq Sultan on Medium</title>
            <link>https://medium.com/@ashiq.sultan?source=rss-eab977776e31------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:46:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashiq.sultan/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[Google Cloud Dataplex Data Lineage, BigQuery & dbt: It Just Works!]]></title>
            <link>https://blog.montrealanalytics.com/google-cloud-dataplex-data-lineage-bigquery-dbt-it-just-works-84531a8c6c83?source=rss-eab977776e31------2</link>
            <guid isPermaLink="false">https://medium.com/p/84531a8c6c83</guid>
            <category><![CDATA[dataplex]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[data-lineage]]></category>
            <category><![CDATA[bigquery]]></category>
            <dc:creator><![CDATA[Ashiq Sultan]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 11:49:47 GMT</pubDate>
            <atom:updated>2023-06-29T16:02:45.306Z</atom:updated>
            <content:encoded><![CDATA[<h3>Google Cloud Dataplex Data Lineage, BigQuery + dbt: It Just Works!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYFX9Aj7oUd1We1Du5pTQg.jpeg" /></figure><p>For users of <a href="https://docs.getdbt.com/"><strong>dbt</strong></a> also working with <strong>Google Cloud (GC), dbt</strong>’s out-of-the-box Data Lineage graph document has been a godsend for a long time. However, users have been looking for a more centralised, native solution in GC for a long time — and ideally, in <strong>Data Catalog</strong> (now part of <strong>Dataplex</strong>).</p><p>Well — Google has definitely listened and granted this wish! <strong>Dataplex </strong>(<strong>Data Catalog)</strong> now has a Lineage feature that allows us to track data movement out-of-the-box too!</p><p><em>See: Google Cloud’s </em><a href="https://cloud.google.com/data-catalog/docs/concepts/about-data-lineage"><em>official page for Data Lineage</em></a><em> (currently in </em><strong><em>Preview</em></strong><em>)</em></p><h3>BigQuery Lineage &amp; dbt</h3><p>For data transformation solutions for Data Warehouses or Data Marts in <strong>BigQuery</strong>, building transformation pipelines using <strong>dbt </strong>allows users to leverage the power of <strong>dbt docs</strong> to consume the lineage graph to build a tracking information picture for our data flow.</p><p>However, since this is a third-party non-GC native solution, a degree of “scaffolding” work has to be done to integrate <strong>dbt</strong>’s<strong> </strong>lineage graph to the wider native GC solutions (e.g., Data Catalog) to build a more complete governance picture. Thus, having lineage capability natively makes it a lot easier to build a full governance view in GC.</p><p>In this blog, we will illustrate our example solution for data model building in <strong>BigQuery </strong>using <strong>dbt</strong>.</p><h3>Our Example: Key Architecture, Products &amp; Services Used</h3><p>Throughout this process, we used the following tools and made some assumptions about the existing infrastructure:</p><ul><li><strong>dbt </strong>CLI version 1.3.0, deployed in GC as a container (for more on different ways of deploying dbt in production, please see <a href="https://docs.getdbt.com/docs/deploy/deployments">this page </a>on <strong>dbt</strong>’s official site).</li><li><strong>Cloud Composer</strong> to schedule, (further) orchestrate and run <strong>dbt </strong>CLI in GC.</li><li>We already have <strong>Data Catalog API </strong>enabled.</li><li><a href="https://medium.com/datatonic">Datatonic</a>’s Enterprise Data Warehouse (EDW), a “two-tier” data architecture that includes a DWH layer and an Analytical layer, with an additional “staging” layer which acts as a transition layer between raw and DWH or DWH to analytical layers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*4lPvSua7DRnBk8uB.png" /><figcaption><em>Fig 1: BigQuery conceptual architecture of a “2-tier” EDW solution</em></figcaption></figure><ul><li>The “Data Warehouse (DWH)” layer uses a more agnostic modelling approach to organise and store data. The “Analytical” layer uses a data modelling approach that is based on a <strong>star schema with a fact constellation</strong>.</li><li>We are building the “example” DWH and an Analytical layer on top for the following data flow (illustrated using <strong>dbt </strong>Lineage Graph):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_K64EEaXvZUU5RRhDwf1MA.png" /><figcaption>Fig 2: Datatonic’s “example” EDW solution data flow</figcaption></figure><h3>Let’s Look at One Table and Its Lineage</h3><p>The table we will focus on is our example dimension table for the analytical layer named <strong>dim_another_example_using_staging</strong>. This table is materialised using a very simple configuration and source SQL and has upstream dependencies as shown below:</p><pre><br>{{<br>    config(<br>      materialized = &#39;table&#39;,<br>      partition_by = {<br>      &quot;field&quot;: &quot;source_partition_timestamp&quot;,<br>      &quot;data_type&quot;: &quot;TIMESTAMP&quot;,<br>      &quot;granularity&quot;: &quot;day&quot;<br>      }<br>    )<br>    }}<br><br><br>SELECT <br>    message_id,<br>    message_description,<br>    source_partition_timestamp,<br>    CURRENT_TIMESTAMP() AS insertion_timestamp<br>FROM<br>    {{ ref(&#39;stg_dwh_example&#39;) }}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VIX8WZwJbPkhkY1lkApSfg.png" /><figcaption>Fig 3: <strong>dim_another_example_using_staging </strong>data lineage</figcaption></figure><h3>Can We View Lineage In BigQuery UI?</h3><p>Yes — we can! All we need to do is enable the API and view the result!</p><p>Let’s take the following pre-requisite steps:</p><ul><li>For our Datatonic example analytics GC project, we have enabled <strong>Lineage API </strong>as shown below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*qpmeO7DHlMUEXMC_uKjmyw.png" /><figcaption>Fig 4: Enabling Data <strong>Lineage API</strong></figcaption></figure><ul><li>We have run <strong>dbt build</strong> (or <strong>dbt run</strong>)</li><li>We have generated and served dbt docs (e.g. locally — port 8080), to compare outputs</li></ul><p>That’s it! We should now be able to see Data Lineage for the table built using <strong>dbt </strong>in <strong>BigQuery </strong>UI as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Be4rtMFiojQ6K5u5OZLgow.png" /><figcaption>Fig 5: <strong>BigQuery </strong>Lineage graph for <strong>dim_another_example_using_staging</strong> table, built using <strong>dbt</strong></figcaption></figure><h3>Some Key Caveats</h3><p>Whilst this is simple, some caveats exist when building tables in <strong>dbt</strong>, which can produce a confusing picture on the lineage graph in BigQuery UI. A couple of such examples are:</p><ul><li>Working with <strong>incremental, insert-overwrite MERGE </strong>strategy</li><li>Deprecated/renamed/moved upstream models in <strong>dbt</strong></li></ul><p>In this section, we will focus on one of the key caveats: working with an <strong>incremental, insert-overwrite MERGE </strong>strategy.</p><p><em>Please see: </em><strong><em>dbt</em></strong><em>’s </em><a href="https://docs.getdbt.com/docs/build/incremental-models#about-incremental_strategy"><em>page</em></a><em> on incremental (specifically, insert-overwrite strategy)</em></p><p>At its core, the <strong>incremental, insert-overwrite </strong>strategy takes a write-append approach to MERGE. However, this works “under the hood” by creating a temp table (named as the same name as the target table + suffix <strong>__dbt_tmp) </strong>with a list of partitions to be replaced on the target table and on the same DML statement, simply replacing those partitions on target when matched with data in the temp table.</p><p>But, this can result in the <strong>BigQuery </strong>UI lineage graph producing a confusing output.</p><h3><strong>Example</strong></h3><p>Look at one of the tables further upstream in the earlier lineage graph (fig 3) — <strong>stg_example</strong>. The config, code and <strong>dbt </strong>lineage for this table is as shown below:</p><pre><br>{{<br>    config(<br>    materialized=&#39;incremental&#39;,<br>    incremental_strategy=&#39;insert_overwrite&#39;,<br>    partition_by={<br>      &quot;field&quot;: &quot;source_partition_timestamp&quot;,<br>      &quot;data_type&quot;: &quot;TIMESTAMP&quot;,<br>      &quot;granularity&quot;: &quot;day&quot;<br>    },   <br>    table_cluster_fields([&#39;sender&#39;, &#39;sender_email&#39;, &#39;message_id&#39;, &#39;message_description&#39;] ),<br>    post_hook=&quot;{{ row_access_policy(&#39;sender_pii_access&#39;) }}&quot;,<br>        )<br>    }}<br><br><br>WITH<br># Example incremental CTE with partition filter<br>example AS (<br>        SELECT <br>            message_id,<br>            message_description,<br>            sender,<br>            sender_email,<br>            source_partition_timestamp <br>        FROM {{ ref(&#39;extr_example&#39;) }}<br>        WHERE source_partition_timestamp &gt;= CAST( {{ load_based_filter_date() }}  AS TIMESTAMP)<br>      <br>)<br><br># Incremental Final Data<br>SELECT<br>    *,<br>    CURRENT_TIMESTAMP() AS insertion_timestamp<br>FROM example</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15eogIGJPWwLO1LP4tCjUg.png" /><figcaption>Fig 6: <strong>stg_example </strong>and upstream lineage via <strong>dbt </strong>docs</figcaption></figure><p>If you now look at the lineage graph in BigQuery UI for this table, it’ll look quite confusing at first glance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sO6ciO-Do9r_pTOjYKWGTg.png" /><figcaption>Fig 7: <strong>stg_example </strong>lineage on <strong>BigQuery </strong>UI</figcaption></figure><p>But, a closer look will show you that BigQuery has built the lineage based on the references on the DML generated by <strong>dbt</strong>, for the MERGE statement (insert-overwrite), which is also shown below:</p><pre><br>      -- generated script to merge partitions into `datatonic-&lt;REDACTED&gt;`.`sandbox_ash_medium_stg`.`stg_example`<br>      declare dbt_partitions_for_replacement array&lt;TIMESTAMP&gt;;<br><br>      <br>      <br>        declare _dbt_max_partition TIMESTAMP default (<br>      select max(source_partition_timestamp) from `datatonic-&lt;REDACTED&gt;`.`sandbox_ash_medium_stg`.`stg_example`<br>      where source_partition_timestamp is not null<br>    );<br><br>        -- 1. create a temp table<br>        <br>      create or replace table `datatonic-&lt;REDACTED&gt;`.`sandbox_ash_medium_stg`.`stg_example__dbt_tmp`<br>      partition by TIMESTAMP_trunc(source_partition_timestamp, day)<br>      cluster by sender, sender_email, message_id, message_description<br>      OPTIONS(<br>      description=&quot;&quot;&quot;This table an example table for data staging&quot;&quot;&quot;,<br>    <br>      labels=[(&#39;domain&#39;, &#39;data_staging&#39;), (&#39;data_steward&#39;, &#39;ashiq_sultan&#39;)],<br>    <br>      expiration_timestamp=TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 12 hour)<br>    )<br>      as (<br>  # Example incremental config  post_hook=row_access_policy(&#39;stg_example&#39;),<br>    <br>    # General config for a full table materialisation (example: a type-1 dimension data staging)<br><br>WITH<br> __dbt__cte__extr_example as (<br>SELECT<br>    message_id,<br>    message_description,<br>    sender,<br>    sender_email,<br>    source_partition_timestamp<br>FROM  `datatonic-&lt;REDACTED&gt;`.`dl_example_for_dbt`.`dl_example_generated`<br>),# Example incremental CTE with paritition filter<br>example AS (<br>        SELECT <br>            message_id,<br>            message_description,<br>            sender,<br>            sender_email,<br>            source_partition_timestamp <br>        FROM __dbt__cte__extr_example<br>        WHERE source_partition_timestamp &gt;= CAST( IFNULL(DATE(_dbt_max_partition), &#39;1990-01-01&#39;)  AS TIMESTAMP)<br>      <br>)<br><br># Incremental Final Data<br>SELECT<br>    *,<br>    CURRENT_TIMESTAMP() AS insertion_timestamp<br>FROM example<br>      );<br><br>    <br><br>      -- 2. define partitions to update<br>      set (dbt_partitions_for_replacement) = (<br>          select as struct<br>              array_agg(distinct TIMESTAMP_trunc(source_partition_timestamp, day))<br>          from `datatonic-&lt;REDACTED&gt;`.`sandbox_ash_medium_stg`.`stg_example__dbt_tmp`<br>      );<br><br>      -- 3. run the merge statement<br><br>    merge into `datatonic-&lt;REDACTED&gt;`.`sandbox_ash_medium_stg`.`stg_example` as DBT_INTERNAL_DEST<br>        using (<br>        select * from `datatonic-&lt;REDACTED&gt;`.`sandbox_ash_medium_stg`.`stg_example__dbt_tmp`<br>      ) as DBT_INTERNAL_SOURCE<br>        on FALSE<br><br>    when not matched by source<br>         and TIMESTAMP_trunc(DBT_INTERNAL_DEST.source_partition_timestamp, day) in unnest(dbt_partitions_for_replacement) <br>        then delete<br><br>    when not matched then insert<br>        (`message_id`, `message_description`, `sender`, `sender_email`, `source_partition_timestamp`, `insertion_timestamp`)<br>    values<br>        (`message_id`, `message_description`, `sender`, `sender_email`, `source_partition_timestamp`, `insertion_timestamp`)<br><br>;<br><br>      -- 4. clean up the temp table<br>      drop table if exists `datatonic-&lt;REDACTED&gt;`.`sandbox_ash_medium_stg`.`stg_example__dbt_tmp`</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L5NXdhW-YxDAPj9ynDhurA.png" /><figcaption>Fig 8: Closer look and we can see that <strong>BigQuery </strong>lineage is doing its job based on the <strong>dbt-generated</strong> DML</figcaption></figure><h3>Conclusion</h3><p>While these caveats should be considered, this combination of tools provides an easy and intuitive way to keep on top of Data Lineage when using Google Cloud. Data Lineage is crucial to any business wanting to know the source and keep track of processing, its data.</p><p>Datatonic, Google Cloud’s 4 X Partner of the Year, is the leading cloud data + AI consultancy for the world’s most ambitious businesses, challenging traditions to deliver tangible innovation at the leading edge of Google Cloud. Our team also has a wealth of experience with dbt, running the Expert Lounge at dbt Labs’ recent London event, Coalesce London. Need help with dbt? Get in touch at <a href="https://datatonic.com/contact/">datatonic.com/contact/</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84531a8c6c83" width="1" height="1" alt=""><hr><p><a href="https://blog.montrealanalytics.com/google-cloud-dataplex-data-lineage-bigquery-dbt-it-just-works-84531a8c6c83">Google Cloud Dataplex Data Lineage, BigQuery &amp; dbt: It Just Works!</a> was originally published in <a href="https://blog.montrealanalytics.com/">${around_the_block}</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding Near-Complete Autonomy to dbt Continuous Deployment Using “Slim Backfills”]]></title>
            <link>https://medium.com/@ashiq.sultan/adding-near-complete-autonomy-to-dbt-continuous-deployment-using-slim-backfills-c1e4f4061926?source=rss-eab977776e31------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1e4f4061926</guid>
            <category><![CDATA[dbt-labs]]></category>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[Ashiq Sultan]]></dc:creator>
            <pubDate>Wed, 19 Oct 2022 10:39:45 GMT</pubDate>
            <atom:updated>2022-10-19T10:39:45.498Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IbMVPdcRx2evZXKmoo50UA.jpeg" /></figure><p><a href="https://www.getdbt.com/">dbt</a> is a great tool for data transformation and is popular with both open-source communities and enterprise-grade users. dbt’s core version is <strong>open-source and highly adaptable</strong> to all main Cloud data warehouse solutions, such as Google BigQuery and Snowflake. This flexibility and versatility allow for some very cool implementations for <strong>solving data management challenges.</strong></p><p>dbt has powerful features to deal with data management of different configurations such as incremental models, snapshots, etc. Within incremental configurations, there are further options such as setting <em>on_schema_change</em> properties to handle table schema changes.</p><p>However, depending on your use case, sometimes a full refresh of models is necessary. A common challenge faced by dbt users is the issue of conducting a full refresh, also known as backfilling in production.</p><p><strong>In this blog</strong>, we will discuss scenarios where a <strong>full refresh</strong> is necessary when there has been <strong>either a schema or code change</strong> for a model and how we can give the CI/CD process near-complete autonomy by <strong>implementing capabilities to organically handle backfills.</strong></p><h3>Background &amp; Assumptions</h3><p>Our aim is to create a near-100% autonomous and intelligent CI/CD process for the following scenario and assumptions:</p><p>1. We are deploying in Google Cloud, using BigQuery for data storage.</p><p>2. We are using the Command Line Interface (CLI) version of dbt.</p><p>3. We have all the necessary infrastructure and security provisions in place for CI/CD processes and dbt workflow execution, including any and all Service Account (SA) requirements.</p><p>4. For most incremental analytical models, we allow the CD process to run backfills only for the models where there has been either a schema or code change. The reasons for this are:</p><ul><li>Most upstream tables in the raw layer are already in existence</li><li>Data was originally available but business requirements excluded certain fields from being pulled into the analytical layer</li><li>Using the dbt <em>on_schema_change </em>config for incremental models isn’t sufficient because they do not deal with historical data</li></ul><p>5. The models which are out-of-scope for this automation are configured as <em>full_refresh = false.</em> Other mechanisms, such as specific tags, can also be used to ensure non-idempotent and/or large loads are not part of any “blunt instrument” automated backfill.</p><p>Using the dbt “state” method is the most preferable choice to create this automated backfill strategy into the CD process (see <a href="https://docs.getdbt.com/reference/node-selection/methods#the-state-method">Understanding dbt “state” method</a>).</p><h3>Key Architecture, Products &amp; Services Used</h3><p>Throughout this process, we used the following:</p><ul><li><a href="https://datatonic.com/insights/data-orchestration-platform/">Datatonic’s DOP framework</a> on Cloud Composer to run the dbt CLI in Google Cloud</li><li><a href="https://medium.com/datatonic">Datatonic</a>’s enterprise data warehouse (EDW/DWH), a “2-tier” data architecture that includes a DWH layer and an Analytical layer, with an additional “staging” layer which acts as a transition layer between raw and DWH or DWH to analytical layers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aHWETxmjAhtLAB2VXzRh6A.png" /><figcaption>Fig 1: BigQuery conceptual architecture of a “2-tier” EDW solution</figcaption></figure><ul><li>For data transformation &amp; management, our solution implements a workflow in productions and runs a set of dbt tasks by using dbt tags (for further reading, see <a href="https://docs.getdbt.com/reference/resource-configs/tags">dbt tags</a>) per the illustration below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YshUVpOgss9RW_AaRZWHZA.png" /><figcaption>Fig 2: dbt data transformation and management</figcaption></figure><ul><li>GitHub for source control and CI/CD</li></ul><p>For this example, we are using both a UAT and production environment with a CI/CD strategy in line with our branch workflow (any merged code to UAT and production only when a release tag is created and per naming convention (e.g., contains “release”))</p><h4>Inspiration From Slim CI</h4><p>One of the key inspirations for solving our challenge was to understand dbt Labs’ “Slim CI” solution.</p><p>The fully-managed version of dbt, <strong>dbt Cloud</strong>, offers Slim CI. Slim CI provides a simpler, more efficient, and cost-effective way to test new and modified dbt models before deploying them into production. By surfacing the job’s most recent successfully-run artefacts, dbt Cloud determines the set of new and modified resources. Thus, we can choose to run only the dbt models for which any code has changed.</p><p>For further reading, have a look at <a href="https://docs.getdbt.com/docs/deploy/cloud-ci-job#understanding-dbt-cloud-slim-ci">Understanding dbt Cloud Slim CI</a>.</p><p>The key methods and techniques behind this process enabled our solution to handle backfills for models where there has been a change and it is determined that the table should be rebuilt and backfilled:</p><ul><li>Using Slim CI for surfacing and comparing previous run artefacts to the latest ones, specifically: <em>manifest.json</em></li><li>Using dbt “state” methods and leveraging the power of dbt to create a targeted framework for a run</li></ul><h4>Our Git Strategy</h4><p>It was vital for us to review the challenge and decide on the best approach to branch workflow for our solution.</p><p>For our solution, the branch workflow has a protected master branch, and each new feature is developed in short-lived feature branches, which are merged back into the Master branch before being deleted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GlNHMKPinv5fU6Ov" /><figcaption>Fig 3: An illustration of Datatonic&#39;s branch workflow for EDW</figcaption></figure><p>Here is an outline of the process:</p><ul><li>We have a master/main branch which contains the most stable release of our code.</li><li>Each person creates a feature branch off the master branch to do their work in.</li><li>Once each feature is complete, it is then merged into the master branch.</li><li>Feature branches are used to develop single features only, and will be deleted once complete.</li><li>Releases are created by tagging the master branch.</li></ul><h3>Our Solution: Continuous Deployment With “Slim Backfills”</h3><p>In the case of our deployment, “Slim Backfills” are a workflow designed to create maximum automation in the CI/CD process by targeting a “full refresh” of models that have been identified as “modified” when changes are merged to the master branch.</p><p>This is established by creating a “360-process” in CI/CD where the previous version of the manifest file is stored in a GCS bucket and later used to compare models/nodes in dbt to determine — using the dbt “state” method — which models have been changed and require backfilling. The design thus allows a very high degree of autonomy in the process of CI/CD.</p><p>Here are the steps we followed in the order of implementation:</p><ul><li>For the deployed production workflow of the dbt run, save the <em>manifest.json</em> file to a GCS store. This file should contain the state of the deployed models as of the currently deployed version (of a data warehouse or analytical project, etc.)</li><li>For the CI/CD pipeline, create a set of processes that will set off a chain of events when a new deployment is triggered.</li><li>Retrieve the previous <em>manifest.json</em> from the GCS bucket, e.g., using a gsutil command like:</li></ul><pre>gsutil cp gs://manifest-location-prod/manifest.json manifest.json</pre><ul><li>Use the dbt “state” method to compare the new version (default) of the <em>manifest.json</em> and compare to the retrieved version to determine the models where there has been a change, either to the schema or the code</li><li>Run the command for the slim backfill; a basic version of this command will be:</li></ul><pre>dbt run --full-refresh --select state:modified+ --state .</pre><ul><li>Once this has been completed, continue with an incremental/regular run per the original deployment and post-deployment processes</li></ul><h4>Update The Production dbt Workflow</h4><p>We decided to update the production workflow so that it should save <em>all</em> the artefacts in the dbt target folder to a GCS bucket as illustrated in the process diagram below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ape6oapt59nNk04k" /><figcaption>Fig 4: An illustration of a simple, batch schedule for dbt UAT &amp; Production workflow(s)</figcaption></figure><p>This process now implements the first requirement for our target solution to build “slim backfill” into the CD process. It stores the <em>manifest.json</em> as part of the process which saves all of the dbt target folder content.</p><h4>Implementation of Slim Backfill to CD Process</h4><p>After implementing a process which stores the artefacts, including those from the currently-deployed version of our dbt solution, we can now implement the full “360-process” for creating near autonomy to the CD process, as shown in the diagram below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DEX1PNpxxJ5dTHHr" /><figcaption>Fig 5: An illustration of “Slim Backfills” incorporated into the CI/CD Process</figcaption></figure><h3>Conclusion</h3><p>By creating a “360-process”, we can now ensure that the continuous deployment process has near-complete autonomy by being able to handle backfills/model rebuild &amp; reload in a targeted and smart way. This approach, on top of bringing a high degree of autonomy, also makes the CD process very efficient and cost-effective, with its highly targeted nature.</p><h3>Key Caveats</h3><p>Whilst it’s great to have a highly independent solution for CI/CD on paper, there are some key reservations to keep in mind when implementing a solution which gives so much power to an autonomous framework:</p><p>1. This solution isn’t “one size fits all”; a full refresh for models done autonomously may not be ideal for some organisations and scenarios, especially if models involve critical business requirements. Some examples include:</p><ul><li>Operational tables, both in terms of use and Egress to other systems</li><li>Key customer or business data</li><li>Very large models that may take many hours to rebuild</li></ul><p>2. In some cases, load idempotency is an issue; you should either set full refresh to false or not use an automated backfill framework for CD.</p><p>3. Generally, automated table rebuilds can be perceived as quite risky for Data Governance and Integrity.</p><p>Some of these can be mitigated by either disabling backfills for critical models or creating a bit more of a workflow around the slim backfills themselves such as using tags or selectors to only backfill or exclude from backfill certain groups of models. That’s one of the great things about dbt — there are many ways to solve challenges around data transformation solutions!</p><p>Datatonic, 4x Google Cloud Partner of the year, and Google Cloud’s Machine Learning Partner of the Year, is the leading cloud data + AI consultancy for the world’s most ambitious brands, challenging traditions to deliver tangible innovation at the leading edge of Google Cloud. We have a wide range of experience with dbt. <a href="https://datatonic.com/contact/">Contact us</a> to find out more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1e4f4061926" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>