<?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 Paul Fry on Medium]]></title>
        <description><![CDATA[Stories by Paul Fry on Medium]]></description>
        <link>https://medium.com/@paul-fry?source=rss-f8e65fb54556------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VHqo64Utxt0emYOA8AS0Uw.jpeg</url>
            <title>Stories by Paul Fry on Medium</title>
            <link>https://medium.com/@paul-fry?source=rss-f8e65fb54556------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:01:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paul-fry/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[Claude Context Engineering]]></title>
            <link>https://paul-fry.medium.com/claude-context-engineering-e100716838df?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/e100716838df</guid>
            <category><![CDATA[context-engineering]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Wed, 25 Nov 2026 15:53:48 GMT</pubDate>
            <atom:updated>2026-11-25T18:13:27.963Z</atom:updated>
            <content:encoded><![CDATA[<h4>How Can I Keep My Context Down?</h4><p><em>This post describes how to stop Claude Code rules from bloating every session or not loading when they should. It’s for engineers whose </em><em>CLAUDE.md file keeps growing.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lNFFR1CHcI9AnvV0" /><figcaption>Photo by <a href="https://unsplash.com/@planetvolumes?utm_source=medium&amp;utm_medium=referral">Planet Volumes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Note: The views described below are my own and don’t represent my employer.</em></p><h3>Table of contents</h3><ol><li>Problem statement</li><li>Three ways to instruct Claude how to load rules</li><li>Verify your rules work as intended</li><li>Blind reviews: keep your context out of it</li><li>Wrapping up</li></ol><h3>1. Problem statement 🧳</h3><blockquote><em>“</em>target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence.<em>” (</em><a href="https://code.claude.com/docs/en/memory"><em>Claude Code docs</em></a><em>)</em></blockquote><p>My old Claude Code setup accidentally bloated up to about 30,000 tokens of rules in every session (I got a little trigger-happy).</p><p>I also found that some rules weren’t even loading as intended — e.g., my Git guide was missed in 24 of the 67 sessions that ran Git commands.</p><h3>2. Three ways to instruct Claude how to load rules</h3><p>My always-on setup is now about 3,000 tokens, roughly a tenth of what it was (both figures are estimates, and I haven’t measured the effect on Claude’s output). I got there by sorting each rule into one of three options, and trimming what was left:</p><ol><li><a href="https://code.claude.com/docs/en/features-overview"><strong>Always-on</strong></a></li></ol><ul><li>Loads rules in every session.</li><li><strong>Use it when:</strong> you want a rule to apply to all sessions.<br>E.g., never share secrets, such as those in .env files.<br>Note: That&#39;s <a href="https://code.claude.com/docs/en/features-overview">&quot;a request, not a guarantee&quot;</a>, so back it with a hook.</li><li><strong>Example usage:</strong> <a href="https://github.com/paulf-999/ai-engineering-playbook/tree/main/src/claude/rules/always_on">My always-on rules | ai-engineering-playbook</a></li></ul><p>2. <a href="https://code.claude.com/docs/en/features-overview"><strong>On-demand</strong></a></p><ul><li>Loads rules conditionally, using a pointer.</li><li><strong>Use it when:</strong> only some tasks need the rule, and you can tell Claude which.<br>E.g., rules about Git patterns and standards.</li><li><strong>Example usage:</strong> <a href="https://github.com/paulf-999/ai-engineering-playbook/tree/main/src/claude/rules/on_demand">My on-demand rules | ai-engineering-playbook</a></li></ul><p>3. <a href="https://code.claude.com/docs/en/memory#path-specific-rules"><strong>Path-scoped</strong></a></p><ul><li>Loads rules when a path pattern is matched.</li><li><strong>Use it when:</strong> a rule applies only to certain file paths.<br>E.g., a SQL style guide, triggered by **/*.sql.</li><li><strong>Example usage:</strong> <a href="https://github.com/paulf-999/ai-engineering-playbook/tree/main/src/claude/rules/path_scoped">My path-scoped rules | ai-engineering-playbook</a></li></ul><h4>Example: On-demand pointer</h4><p>The detail lives in git.md (adapted from mine):</p><pre>&lt;!-- CLAUDE.md: loads every session --&gt;<br>Before any git command, read ~/.claude/on_demand/git.md</pre><pre>&lt;!-- git.md: loads on demand --&gt;<br># Git</pre><pre>- **Logical boundary:** commit once a task is done and its checks pass.<br>- **No stacked PRs:** branch each PR from `main`, never from another open PR&#39;s branch.</pre><p>Say when to read it, as “see also git.md&quot; is easy to skip. Claude can still skip it, so keep critical rules always-on. <a href="https://code.claude.com/docs/en/memory">Anthropic recommends skills</a> for this group, but I keep skills for step-by-step procedures, and use pointers for standards to follow, such as this one.</p><h4>Example: Path-scoped rule</h4><pre>---<br>paths:<br>  - &quot;**/models/**/*.sql&quot;<br>  - &quot;**/dbt_project.yml&quot;<br>---<br># dbt standards<br>Reference tables with ref() or source(), never schema.table.</pre><h3>3. Verify your rules work as intended</h3><h4>3.1 Do rules get missed? 🫥</h4><p>Sadly, yes. I searched my session transcripts for rules of all three types that applied, but were never loaded or read:</p><ul><li><strong>Always-on</strong> (security and behaviour rules): missed in <strong>0 of 105</strong> sessions.</li><li><strong>On-demand</strong> (Git guide, in sessions that ran Git commands): missed in 6<strong> of 67 rules</strong>.</li><li><strong>Path-scoped</strong> (Python and Bash guides): missed in <strong>0 of 10</strong>.</li></ul><p>As you can see:</p><ul><li><strong>Always-on and path-scoped:</strong> these were triggering as intended, for files inside the project.</li><li><strong>On-demand:</strong> my Git guide was slipping through the net in over a third of the sessions I checked.</li><li><strong>Why:</strong> some on-demand rules, e.g., my Git rules, don’t have anything I can confidently use as a trigger, such as a file path.</li></ul><h4>3.2 Find missed rules 🔍</h4><p>I developed a script named <a href="https://github.com/paulf-999/ai-engineering-playbook/blob/main/src/py/find_missed_rules.py">find_missed_rules.py</a> to read your Claude Code transcripts. It counts how often a user-level path-scoped rule was skipped, when it should have been triggered.</p><p>For example:</p><pre>$ python3 find_missed_rules.py ~/.claude 2026-11-19<br>python.md     missed 4 of 12<br>bash.md       missed 2 of 4</pre><h4>3.3 Monitor and limit your always-on rules 📏</h4><p>Always-on rules have the opposite problem: they always load, so they can accidentally creep up over time, one perfectly sensible line at a time.</p><h4>Token budget checker 🚦</h4><p>To mitigate this, I developed a script named <a href="https://github.com/paulf-999/ai-engineering-playbook/blob/main/src/sh/claude_validate_always_on_budget.sh">claude_validate_always_on_budget.sh</a> that estimates everything that always loads, including skill and agent descriptions (at 4 characters a token), and fails above 3,300 tokens. A pre-commit hook runs it whenever those files change, and CI runs it again:</p><pre>- id: claude_validate_always_on_budget<br>  entry: src/sh/claude_validate_always_on_budget.sh<br>  language: script<br>  pass_filenames: false<br>  files: ^(CLAUDE\.md|src/claude/.*|\.claude/.*)$</pre><p>With the limit lowered to 3,000 to show a failure:</p><pre>ERROR: always-on context is ~3171 tokens, over the 3000-token budget.</pre><h3>4. Blind reviews: keep your context out of it 🙈</h3><p>I use <strong>blind reviewers</strong>, i.e., a separate Claude session that sees only the work, the task and the criteria.</p><p>A reviewer given the author’s background can unintentionally pick up the author’s bias. A blind review ensures it approaches the work cold, with none of that context.</p><h4>Example: Blind review of a new skill</h4><p>Say I’ve built a new skill with Claude, e.g., one that creates pull requests. The session that helped build it already knows what I meant, so it can read past any gaps. Instead, I’d start a separate session, where the reviewer:</p><ul><li><strong>Sees:</strong> the SKILL.md file, the task (&quot;review this skill&quot;) and the criteria, e.g., are the steps clear, and is it obvious when to use it?</li><li><strong>Doesn’t see:</strong> our conversation, or why I made the choices I did.</li><li><strong>Reports:</strong> whatever it couldn’t follow from the file alone.</li></ul><h3>5. Wrapping up</h3><h4>5.1 If you only do one thing</h4><ul><li>Load less.</li><li>Check what’s missed.</li><li>Cap what’s left.</li><li>Give reviewers even less.</li></ul><p>If you only do one, <strong>load less</strong>: move your largest language or tool guide to a path-scoped rule.</p><h4>Example: Prompt to sort your own rules</h4><pre>Read CLAUDE.md and every file in .claude/rules/. For each rule, say whether<br>it should be always-on, on-demand or path-scoped, and why. Flag any to delete.<br>Don&#39;t change any files.</pre><p>Enjoy!</p><h3>5.2 Useful resources</h3><ul><li><a href="https://code.claude.com/docs/en/memory">How Claude remembers your project | Claude Code docs</a></li><li><a href="https://github.com/paulf-999/ai-engineering-playbook">My Claude Code setup | ai-engineering-playbook</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e100716838df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform Associate Certification: Practical Lessons for Data Teams]]></title>
            <link>https://medium.com/geekculture/terraform-associate-certification-practical-lessons-for-data-teams-ecb648773318?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecb648773318</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Thu, 30 Oct 2025 06:17:26 GMT</pubDate>
            <atom:updated>2026-02-17T08:45:46.823Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>What the Terraform Associate certification taught me about using Terraform effectively in a team.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*nPWw2SIuYXp3Ge0mNaA-Xw.png" /></figure><h3>🔍 <strong>Biggest takeaways</strong></h3><ul><li>Overall, it’s less about memorising commands, more about understanding how Terraform behaves and how teams use it effectively.</li><li>Terraform does more behind the scenes than you might think-understanding what happens when you run commands like init and plan makes the tool much easier to reason about.</li><li>Managing environments can be done in several ways; knowing when to use workspaces versus separate folders helps avoid confusion later.</li><li>The exam covers topics related to Terraform Cloud (which I don’t use), covering features I hadn’t used before — so you do need <em>some</em> familiarity.</li></ul><h3>About the Exam</h3><p>The <strong>Terraform Associate certification</strong> is designed for individuals who regularly use Terraform and seek to demonstrate a comprehensive understanding of its practical application. It covers key concepts like <strong>state management</strong>, <strong>variables</strong>, <strong>modules</strong>, <strong>workspaces</strong>, and <strong>Terraform Cloud</strong>.</p><p>It’s less about memorising commands and more about understanding <em>how Terraform behaves</em> — how dependencies are resolved, and what happens behind the scenes during commands like init or apply.</p><p>To prepare, I initially used <a href="https://www.udemy.com/course/terraform-beginner-to-advanced/?ranMID=39197&amp;ranEAID=JVFxdTr9V80&amp;ranSiteID=JVFxdTr9V80-Ptd1ryXL4jrBiwcQ9HfpzA&amp;utm_source=aff-campaign&amp;LSNPUBID=JVFxdTr9V80&amp;utm_medium=udemyads"><strong>this Udemy course</strong></a>, which covers Terraform from beginner to advanced. It’s a great resource but a long one — around <strong>20 hours</strong> of content — so it’s worth breaking into smaller chunks and focusing on the parts that align most closely with the <strong>Associate</strong> exam objectives.</p><h3>Context</h3><p>Before this, most of my Terraform use had been for managing AWS resources. More recently, I’ve been focusing on how Terraform applies to data platforms — particularly through the Snowflake provider — which introduces some different considerations around state, roles, and grants compared to traditional cloud infrastructure.</p><p>That shift also made the exam content more relevant. Questions about environment management, module structure, and remote state reinforced patterns I’d seen in practice — especially the trade-offs between workspaces and separate environment folders.</p><h3>Concepts That Weren’t Immediately Obvious</h3><p>While preparing for the certification, a few areas stood out as less straightforward — things that only really made sense after experimenting or digging deeper into the docs.</p><p><strong>State Management and Imports</strong></p><ul><li>Commands like terraform state mv, terraform state show, and terraform import are less frequently used but essential when working with existing infrastructure.</li><li>terraform force-unlock can release a stuck state lock, though it should be used with caution.</li><li>terraform taint marks resources for recreation on the next apply — useful when you need a clean rebuild.</li><li>Understanding <em>state locking</em> helped me appreciate how Terraform prevents concurrent changes — especially in collaborative environments.</li></ul><p><strong>Providers and Modules</strong></p><ul><li>Providers are installed during terraform init, which is also when Terraform validates provider versions and downloads necessary plugins.</li><li>To keep providers up to date, you can use terraform init -upgrade, or review what’s available with terraform providers lock and provider upgrade tools.</li><li>Modules don’t need to be public — they can be local or hosted in private registries or repositories.</li><li>Remember that <em>child modules</em> inherit variables only when explicitly passed; they don’t automatically get access to parent variables.</li></ul><p><strong>Terraform Cloud (Limited Exposure)</strong></p><ul><li>I hadn’t used Terraform Cloud before the exam, so a few of those questions caught me off guard.</li><li>Some features mentioned, such as team management, audit logging, and private network connectivity, are specific to paid plans.</li><li>Even though I still primarily use the CLI, learning about Terraform Cloud gave me a better sense of how teams use Terraform at scale.</li></ul><p><strong>Useful CLI Commands</strong></p><ul><li>terraform console lets you evaluate expressions interactively — a great way to test variable values and for_each logic.</li><li>terraform plan -destroy lists resources scheduled for removal.</li><li>terraform show or terraform state show can be used to inspect resource IDs and current values.</li></ul><p><strong>Misc (Variable Precedence, Logging)</strong></p><ul><li>Revisiting variable definition precedence was useful: Terraform loads values from multiple places, and the order matters.</li><li>For troubleshooting, setting TF_LOG=TRACE provides verbose output, and TF_LOG_PATH directs logs to a file — handy for debugging state or provider issues.</li></ul><h3>Resources That Helped</h3><p>I used a small number of resources but found them genuinely useful:</p><ul><li><strong>HashiCorp Learn:</strong> The official tutorials are well structured and map closely to the exam format.</li><li><strong>Zeal Vora’s Udemy course:</strong> Covers all the exam objectives and goes into Terraform Cloud in just enough detail to understand it.</li><li><a href="https://www.udemy.com/course/terraform-associate-practice-exam/learn/quiz/4777084/test#overview"><strong>Udemy Practice Exams by Zeal Vora</strong></a>: Easily the most useful part of my prep — the questions are realistic, detailed, and help clarify where you might be over- or under-confident.</li><li><strong>Tutorials Dojo practice exams:</strong> Also close in style and difficulty to the real questions.</li><li><strong>HashiCorp documentation:</strong> Still the best source for understanding behaviour that isn’t always obvious in videos or courses — especially around provider parsing and backends.</li></ul><h3>Final Thoughts</h3><p>The Terraform Associate certification was a useful checkpoint — less about the credential itself, and more about confirming that my day-to-day use aligns with common practices.<br>It also prompted me to dig deeper into some of Terraform’s finer details, especially around syntax, environment structure, and how teams collaborate on infrastructure as code.</p><p>For anyone already using Terraform, I’d recommend the certification not as a box-ticking exercise, but as a structured way to strengthen how you think about and apply it — particularly when working as part of a team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecb648773318" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/terraform-associate-certification-practical-lessons-for-data-teams-ecb648773318">Terraform Associate Certification: Practical Lessons for Data Teams</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake-Terraform Provider: Version 1.0 Released]]></title>
            <link>https://medium.com/geekculture/snowflake-terraform-provider-version-1-0-released-038b5caee9e6?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/038b5caee9e6</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Tue, 21 Jan 2025 15:36:10 GMT</pubDate>
            <atom:updated>2025-01-21T15:36:10.599Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why Now is the Perfect Time to Adopt It</h4><p>The <a href="https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs">Snowflake-Terraform provider</a> reached a major milestone with its <strong>v1.0 release in December 2024</strong>. Earlier versions suffered from well-documented challenges that hindered adoption. With extensive codebase refactoring, these issues have been resolved, making v1.0 the ideal starting point for your Terraforming-Snowflake journey.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/0*5-xiH68E_6Agbeof.png" /></figure><h3>What Was Holding Back Adoption of the Snowflake Terraform Provider?</h3><p>Before version 1, users faced several challenges:</p><ul><li><strong>Grants Management</strong>: (as described in the <a href="https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#redesigning-grants">repo’s roadmap</a>) <em>“Grants proved to be one of the most common pain points for the provider’s users”</em>.</li><li><strong>Snowflake Identifiers</strong>: Errors in configurations were common, second only to grant issues.</li><li><strong>GA Feature Gaps</strong>: Support for Snowflake’s newer features was incomplete.</li><li><strong>Resource Differentiation</strong>: Objects like stored procedures and functions lacked type-specific implementations, causing compatibility issues.</li></ul><h3>Version 1: Stabilised and Simplified</h3><p>Version 1 addresses these challenges through key refactoring and new standards:</p><ul><li><a href="https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/account_role"><strong>snowflake_account_role</strong></a> replaces snowflake_role for streamlined role management.</li><li><a href="https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_ownership"><strong>snowflake_grant_ownership</strong></a> eliminates redundancy by replacing grants like snowflake_database_grant.</li><li><strong>Type-Specific Resources</strong>: <a href="https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/procedure_sql"><strong>snowflake_procedure_sql</strong></a> and similar variants replace the generic snowflake_procedure for better clarity.</li></ul><p>Explore the complete list of supported resources and data sources in the <a href="https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs">documentation</a>.</p><h3>Why Adopt Version 1 Now</h3><p>If you haven’t already, now is the perfect time to start your Terraforming-Snowflake journey with Terraform.</p><h4>Version 1.0 = Far Fewer Breaking Changes Per-Release</h4><p>With the major refactoring introduced in version 1, you can also expect far fewer breaking changes in future releases. For example, with revised, well-thought-out standards (e.g., resources like snowflake_procedure have been replaced with snowflake_procedure_sql), there is confidence that the codebase will remain far more stable.</p><h4>Existing Users: How to Migrate to Version 1</h4><p>If you’re using an earlier version, transitioning to version 1 may require some refactoring. The provider has a <a href="https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md">migration guide</a> to help you migrate your Terraform config to the newest version.</p><h3>Hot Tip: Organising Terraform Code for Snowflake</h3><p>Scaling your Terraform setup requires a clear folder structure. The post below provides some great tips on how to cater to/manage multiple Terraform environments:</p><p><a href="https://blog.devops.dev/3-levels-of-structure-terraform-projects-c8344810009c">3 Levels of structure terraform projects</a></p><p>Thinking about how to organise/categorise the differing Snowflake objects types isn’t trivial, but the post below offers a solid approach:</p><p><a href="https://jeremiahhansen.medium.com/a-new-approach-to-database-change-management-with-snowflake-8e3f0fee281">A New Approach to Database Change Management with Snowflake</a></p><h3>Recommended Directory Structure</h3><p>Based on these tips (and lots of trial and error), here’s my recommended directory structure for a Snowflake-Terraform project:</p><pre>terraform/  <br>├── global/  <br>│   ├── 1_roles_and_grants/  <br>│   ├── 2_account_level_objects/  <br>│   ├── 3_schema_level_objects/  <br>├── environments/  <br>│   ├── prod/  <br>│   │   ├── modules/  <br>│   │   │   ├── database/  <br>│   │   │   ├── tables/  <br>│   │   │   └── views/  <br>│   └── dev/</pre><h4>Key Organisation Callouts:</h4><ul><li><strong>Environment Segmentation</strong>: Isolate configurations for each environment (e.g., dev, prod) for easier management. Use directories, rather than Terraform workspaces.</li><li><strong>Modularisation</strong>: Break down resources into smaller, reusable modules, especially for different types of Snowflake objects. For example, create modules for repeatable patterns like granting usage on all tables/views in a database to a given role.</li><li><strong>Account vs. Database Objects</strong>: Separate account-level resources (roles, warehouses) from database-level objects (tables, views) to simplify management.</li></ul><h3>Next Steps: Learn More — CI/CD and Terraform</h3><p>For a deeper dive into automating Snowflake deployments with Terraform in CI/CD pipelines, check out my earlier post, <a href="https://quickstarts.snowflake.com/terraforming-snowflake"><em>Terraforming Snowflake</em></a>.</p><p>If you’re experienced with Snowflake but new to Terraform, I recommend the following quickstart guide:<br> <a href="https://quickstarts.snowflake.com/terraforming-snowflake"><strong>Terraforming Snowflake | quickstarts.snowflake.com</strong></a>. It covers:</p><ul><li>Basic Terraform usage</li><li>How to create users, roles, databases, schemas, and warehouses in Terraform</li><li>How to manage objects from code/source control</li></ul><h3>Conclusion</h3><p>With the stability and improvements introduced in version 1, there’s never been a better time to adopt the Snowflake-Terraform provider. Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=038b5caee9e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/snowflake-terraform-provider-version-1-0-released-038b5caee9e6">Snowflake-Terraform Provider: Version 1.0 Released</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[‘Terraforming Snowflake’]]></title>
            <link>https://medium.com/geekculture/terraforming-snowflake-355ef96fbbec?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/355ef96fbbec</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 17:26:26 GMT</pubDate>
            <atom:updated>2025-02-20T06:31:54.105Z</atom:updated>
            <content:encoded><![CDATA[<h4>Snowflake / How-to</h4><h4>Automate the Deployment of Snowflake Objects using CI/CD Pipelines</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*d3Zk2LpKjxtYEjxz.png" /></figure><p><em>This post explains how to automate the deployment of Snowflake objects using Terraform and CI/CD pipelines, addressing the issues of manual management with a version-controlled, code-driven approach.</em></p><h4>Agenda</h4><ol><li>Problem Statement</li><li>Setup</li><li>Automating Snowflake with CI/CD Pipelines</li><li>Considerations: Upskilling Your Team for Terraform</li><li>Summary</li><li>Useful Resources</li></ol><h3>1. Problem Statement</h3><blockquote>“Who Changed My Snowflake Role/Object Permissions, and Why?”</blockquote><ul><li><strong>Inconsistent Privileges</strong>: Privileges and roles are created or modified ad-hoc without a centralised record. This leads to confusion when users don’t know which permissions have been granted/revoked.</li><li><strong>Lack of Visibility</strong>: Multiple people create or update roles/permissions in isolation, making it difficult to track who made changes or why.</li><li><strong>Manual Errors</strong>: Mistakes are likely when privileges/grants are applied manually, and the downstream impact isn’t fully tested/understood.</li></ul><p>These issues above create security gaps and generally make it hard to manage Snowflake environments at scale.</p><h4>Solution: Terraform + CI/CD Pipelines</h4><p>Using Terraform, you can define your Snowflake resources, roles and grants in code, ensuring that changes are traceable. By integrating Terraform with CI/CD pipelines, you can automate Snowflake object deployments to ensure:</p><ol><li>Only service account users can deploy Snowflake changes.</li><li>All changes are peer-reviewed and approved before being applied.</li></ol><h3>2. Setup</h3><p>The steps below describe how to install and use Terraform and the Snowflake-Terraform provider on your local machine.</p><h4>2.1. Install Terraform</h4><p>Install Terraform by following the <a href="https://developer.hashicorp.com/terraform/downloads">official guide</a>, then verify by running the CLI command: terraform --version</p><h4>2.2. Configure the Terraform-Snowflake Provider</h4><p>To allow Terraform to manage Snowflake resources (e.g., databases, tables, roles), I follow the standard of creating the file providers.tf to define my Snowflake provider config:</p><pre>terraform {<br><br>    required_version = &quot;&gt;= 1.0.0&quot;<br><br>    required_providers {<br>        snowflake = {<br>            source = &quot;Snowflake-Labs/snowflake&quot;<br>            version = &quot;~&gt; 0.97.0&quot;<br>        }<br>    }<br>}<br><br>provider &quot;snowflake&quot; {<br>    account   = var.SNOWFLAKE_ACCOUNT<br>    user      = var.SNOWFLAKE_USER<br>    password  = var.SNOWFLAKE_PASSWORD<br>    role      = var.SNOWFLAKE_ROLE<br>    warehouse = var.SNOWFLAKE_WAREHOUSE<br>}</pre><h4>2.3. Set Up Environment Variables</h4><p>In the above providers config, the Snowflake parameters values are created from variables (i.e., var.&lt;something&gt;). And rather than hardcoding credentials, I use environment variables prefixed with TF_ instead of hardcoding credentials. Set them in your shell:</p><pre>export TF_VAR_snowflake_account=”your_account”<br>export TF_VAR_snowflake_user=”your_username”<br>export TF_VAR_snowflake_role=”your_role”<br>export TF_VAR_snowflake_private_key_path=”path_to_key”<br>export TF_VAR_snowflake_region=”your_region”</pre><h4>2.4. Define Snowflake Resources</h4><p>Finally, use Terraform to define your Snowflake resources. For example:</p><pre>resource “snowflake_database” “example_db” {<br> name = “EXAMPLE_DB”<br> comment = “Created by Terraform”<br>}<br><br>resource &quot;snowflake_schema&quot; &quot;example_schema&quot; {<br> database = snowflake_database.example_db.name<br> name = &quot;EXAMPLE_SCHEMA&quot;<br>}<br><br>resource &quot;snowflake_table&quot; &quot;example_table&quot; {<br> database = snowflake_database.example_db.name<br> schema = snowflake_schema.example_schema.name<br> name = &quot;EXAMPLE_TABLE&quot;<br> column { name = &quot;id&quot;; type = &quot;NUMBER&quot; }<br> column { name = &quot;name&quot;; type = &quot;STRING&quot; }<br>}</pre><p>I’m not going to go over the syntax and/or concepts of Terraform. However, <a href="https://developer.hashicorp.com/terraform/tutorials/aws-get-started">this link</a> provides a good introductory overview, using examples of how to deploy AWS resources.</p><h3>3. Automating Snowflake with CI/CD Pipelines</h3><p>To ensure that all Snowflake changes go through a controlled process, you can integrate Terraform within CI/CD pipelines. Whereby you trigger a Terraform stage/CICD step whenever a Pull Request within your Snowflake Git repo. The approach for handling sensitive values like TF_VAR_SNOWFLAKE_ACCOUNT, TF_VAR_SNOWFLAKE_USER will depend on the CI/CD technology used, e.g., in Azure DevOps, you’d use secure pipeline variables or variable groups.</p><p><strong>Terraform-Snowflake CI/CD Pipeline Steps</strong></p><p>Described below are the 3 high-level steps you’d typically perform with a Terraform-Snowflake CI/CD Pipeline:</p><ol><li><strong>Initialize Terraform</strong>: Run terraform init to download the Snowflake provider and set up the Terraform environment files.</li><li><strong>Plan Changes</strong>: Runterraform plan to generate a preview of the changes to be applied.</li><li><strong>Apply Changes</strong>: Following approval(s) and/or trigger rules, runs terraform apply to apply the changes to your Snowflake environment.</li></ol><h3>4. Considerations: Upskilling Your Team for Terraform</h3><p>While Terraform simplifies Snowflake management, it introduces a need for your team to learn and understand how to use Terraform and the Terraform-Snowflake provider. If your team is new to Terraform, I’d recommend focussing upskilling on the following 3 key areas:</p><ul><li><strong>Terraform Basics</strong>: Understanding how Terraform configurations are structured, how to write resource definitions.</li><li><strong>State Management</strong>: Learning how Terraform maintains the state of your infra and best practices for managing that state across environments.</li><li><strong>Collaboration</strong>: Adopting a workflow where infrastructure changes are reviewed and applied through version control systems. Requires a familiarity with CI/CD processes.</li></ul><p>By ensuring your team has the necessary skills, you can fully leverage Terraform’s benefits and create a more robust, automated Snowflake infrastructure management process.</p><h3>5. Summary</h3><p>Manually managing Snowflake resources, grants and privileges at scale <strong><em>is difficult</em></strong>, and stressful! By using Terraform, you can define your Snowflake resource configurations in code, ensuring visibility, consistency, and easier management. Integrating Terraform with a CI/CD pipeline ensures that changes are automated, reviewed, and tracked, creating a smooth process for managing Snowflake infrastructure at scale.</p><p>By using Terraform, you can bring order to your manually deployed Snowflake environments &amp; ultimately foster greater collaboration. Particularly when used as part of CI/CD pipeline deployments.</p><p>See the resources below to start developing your own ‘Terraformed-Snowflake’ using CI/CD pipelines. Enjoy!</p><h3>6. Useful Resources</h3><h4>1. ‘Terraforming Snowflake’ — Snowflake User Guide</h4><p>If you have limited Terraform expertise, but are experienced with Snowflake, I recommend going through the following Snowflake user guide: <a href="https://quickstarts.snowflake.com/guide/terraforming_snowflake/index.html#0">Terraforming Snowflake | quickstarts.snowflake.com</a>.</p><p>It covers:</p><ul><li>Basic Terraform usage</li><li>How to create users, roles, databases, schemas, and warehouses in Terraform</li><li>How to manage objects from code/source control</li></ul><h4>2. <a href="https://select.dev/posts/snowflake-terraform">Terraform for Streamlined Snowflake Management — select.dev</a></h4><p>If you have some Terraform expertise, but gaps in knowledge on how to implement Terraform within CI/CD pipelines, check out the following blog post: <a href="https://select.dev/posts/snowflake-terraform">Terraform for Streamlined Snowflake Management — select.dev</a>.</p><p>This post carries on from Snowflake’s user guide &amp; describes how it can be applied to a CI/CD pipeline.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=355ef96fbbec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/terraforming-snowflake-355ef96fbbec">‘Terraforming Snowflake’</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Profiling Using Great Expectations]]></title>
            <link>https://medium.com/geekculture/data-profiling-using-great-expectations-17776f140cdc?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/17776f140cdc</guid>
            <category><![CDATA[data-profiling]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[great-expectations]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 10:16:44 GMT</pubDate>
            <atom:updated>2024-01-19T06:11:03.615Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Quality / Data Profiling</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*R-5mDpmGVhuJb-QI1Q0ygg.png" /></figure><p>Managing the breadth of data quality (DQ) issues in your data landscape can be overwhelming. In this blog post, we’ll explore the options available for using data profiling to address these issues. I’ll share a solution I’ve developed that uses Great Expectations to profile in bulk a list of input tables from Snowflake. We’ll evaluate the pros and cons of using Great Expectations to guide your decision-making process.</p><h4>Agenda</h4><ol><li>Problem Statement — DQ Issues, Everywhere!</li><li>Main Approaches for Performing Data Profiling</li><li>What is Great Expectations?</li><li>(Bulk) Data Profiling Solution Using Great Expectations</li><li>Evaluation of Great Expectations</li><li>Summary</li></ol><h3>1. Problem Statement — DQ Issues, Everywhere!</h3><p>Your organisation feels inundated with data quality issues and wants to introduce more data quality measures throughout your data landscape. But:</p><ul><li>What DQ issues should they tackle first?</li><li>How do you prioritise which DQ solutions to deploy?</li><li>What are some of the most common DQ issues you face?</li></ul><p>Data profiling can greatly facilitate this, by developing descriptive statistics to highlight normal vs outlier data within your dataset. However, profiling one table is of little use, you really need to perform data profiling in bulk.</p><h4>Ideal Solution</h4><p>In an ideal world, you’d point a script to a set of tables and generate a data profile report, highlighting per table:</p><ul><li>The types of data quality issues identified.</li><li>And how common these issues are.</li></ul><h3>2. Main Approaches for Performing Data Profiling</h3><p>When looking to carry out data profiling, you have three options:</p><ol><li><strong>Manual Data Profiling</strong>: error-prone, difficult to maintain, doesn’t scale well.</li><li><strong>Commercial Data Profiling Tools</strong>: often bound to specific data platform providers, limiting standalone use (e.g., Talend or Informatica).</li><li><strong>Open Source Tools</strong>: limited adoption, but the data quality platform <a href="https://greatexpectations.io/">Great Expectations</a> is a notable open-source solution.</li></ol><h3>3. What is Great Expectations?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*r9ASLZWU02Eh5rcYi9NMqA.png" /></figure><p><a href="https://greatexpectations.io/">Great Expectations</a> (GX) is an open-source data quality platform. Its key features include:</p><ul><li><a href="https://docs.greatexpectations.io/docs/reference/learn/terms/expectation/">Expectations</a>: creates assertions about your data, defining rules like value ranges for a given column</li><li><a href="https://legacy.docs.greatexpectations.io/en/0.7.11/guides/profiling.html">Automated Data Profiling</a>: Generates basic statistics and a suite of expectations based on observed data.</li><li><a href="https://docs.greatexpectations.io/docs/reference/learn/terms/validator">Data Validation</a>: Validates expectations against data batches.</li><li><a href="https://docs.greatexpectations.io/docs/reference/learn/terms/data_docs">‘Data Docs’ Generation</a>: Human-readable HTML documentation, that renders (GX) Expectation Suites and validation results:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CnkMTiaR3NN1b6ge.png" /></figure><p>These HTML docs contain both your Expectation Suites as well as your data validation results each time a validation is run.</p><h3>4. (Bulk) Data Profiling Solution Using Great Expectations</h3><p>I’ve developed a solution that uses Great Expectations’ automated data profiling tool in conjunction with a Python script and Makefile to perform bulk data profiling on Snowflake data. The code used is available in my GitHub repo (link below):</p><p><a href="https://github.com/paulf-999/data_profiling_w_great_expectations">GitHub - paulf-999/data_profiling_w_great_expectations</a></p><p>As mentioned above, profiling a single table is of little use, and I wanted to make the execution repeatable using different inputs (i.e., config-driven).</p><p>This solution does just that — it effectively uses a Makefile to orchestrate the execution of a config-driven Python script. Whereby inputs fetched from the config file allow the user to customise what data they profile.</p><p><strong>Prerequisites</strong></p><ol><li>.env file: use this to configure your Snowflake credentials.</li></ol><p>2. config.yaml: Use this to define your list of input Snowflake tables.</p><p><strong>Usage: </strong>use the single command, make all to:</p><ul><li>Initiate bulk data profiling on the input tables listed in the config file.</li><li>Execute all of the steps required to install, profile and summarise your profiled data in generated (GX) HTML docs.</li><li>Whereby these steps go from installing the various python dependencies in a virtualenv, to generating data profiles/expectation suites &amp; generating <a href="https://legacy.docs.greatexpectations.io/en/latest/reference/core_concepts/data_docs.html#data-docs">GX data docs</a>.</li></ul><h3>5. Evaluation of Great Expectations</h3><p>While the solution I’ve developed is simple to use, adaptable and generates great output, using Great Expectations wasn’t without its issues. Let’s examine the pros and cons of using Great Expectations:</p><h4>Pros</h4><ol><li><strong>Flexibility: </strong>supports a variety of data sources, from Excel to Snowflake.</li><li><strong>Automated Data Profiling</strong>: more efficient than manual methods.</li><li><strong>Data Documentation</strong>: generates clear, human-readable (HTML) Docs.</li><li><strong>Batch Data Validation</strong>: validates expectations against data batches, rather than per-table</li><li><strong>Simple Definitions for Expectations: </strong>facilitates cross-team collaboration.</li></ol><h4>Cons</h4><ol><li><strong>Learning Curve</strong>: Initial complexity for new users.</li><li><strong>Community and Adoption</strong>: Reliant on a growing open-source community with limited resources.</li><li><strong>Evolution and Updates</strong>: ongoing development may lead to pivots in solutions per release.</li></ol><p><strong>Learning Curve</strong></p><ul><li>Navigating Great Expectations may initially seem complex, where a lot of concepts are thrown at you right away, see <a href="https://docs.greatexpectations.io/docs/reference/learn/conceptual_guides/gx_overview">GX Overview</a>.</li><li>There is a <a href="https://docs.greatexpectations.io/docs/oss/tutorials/quickstart/">quickstart guide</a> to initially get you going, and for subsequent setups, the documentation talks about instead using the <a href="https://docs.greatexpectations.io/docs/0.16.16/guides/expectations/data_assistants/how_to_create_an_expectation_suite_with_the_onboarding_data_assistant/">GX data assistant</a> (i.e., an interactive setup prompt) to simplify the process.</li><li>However, as mentioned, I wanted to make this process repeatable and config-driven, so I scripted the setup steps (see <a href="https://github.com/paulf-999/data_profiling_w_great_expectations/blob/main/Makefile#L34C1-L34C8">makefile — install | github.com</a>).</li><li>The main output/driver needed by GX is for the file reat_expectations.yml to be created. This stores the main configurations for your GX project (e.g., data source details). However, the contents of this file are very bespoke, hence why I sought to script the process and ended up <a href="https://github.com/paulf-999/data_profiling_w_great_expectations/blob/main/src/templates/jinja_templates/great_expectations.yml.j2">creating a Jinja template</a> to recreate it.</li></ul><p><strong>Community and Adoption</strong></p><p>Inconsistent documentation and significant changes per-GX release can pose challenges:</p><ul><li>Inconsistent Documentation: I found myself regularly cross-referencing the <a href="https://docs.greatexpectations.io/docs/oss">latest OSS docs</a> with <a href="https://legacy.docs.greatexpectations.io/en/latest/">legacy docs</a>, as at times, it felt as if they hadn’t quite managed to migrate all of the legacy content over.</li><li>Significant changes, per release: as described in <a href="https://greatexpectations.io/blog/the-fluent-way-to-connect-to-data-sources-in-gx">this GX blog post</a>, the recommended way to connect to a data source significantly changes before version 0.16 and after 0.16 — <a href="https://www.youtube.com/watch?v=589ohvCFQH4">where the new approach is to use fluent</a>. This change has large ramifications on the codebase.</li></ul><p><strong>GX ‘Data Docs’ — Custom Renderer Needed for Data Profiler Output?</strong></p><ul><li>When generating the output of the GX ‘data docs’, you can control what content to keep and omit, as well as what ‘renderer’(s) to use.</li><li>By default, GX doesn’t render profiling results in the generated output. I found this only by reviewing the above-mentioned <a href="https://legacy.docs.greatexpectations.io/en/0.11.6/how_to_guides/spare_parts/data_docs_reference.html#using-custom-views-and-renderers">‘legacy’ GX documentation</a>.</li><li>And to instruct GX to render the profiling output, you need to explicitly say so within the great_expectations.yml file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64hTrrKkI2lkhgJ88U5aQg.png" /></figure><ul><li>Strictly speaking, you’re supposed to create your own custom page renderer to customise the output.</li><li>But at this point, I’d invested too much time in understanding GX’s patchy documentation, API and legacy docs. And as such, I just ended up fixing the HTML output myself! Using regex to find and replace content. See <a href="https://github.com/paulf-999/data_profiling_w_great_expectations/blob/main/src/py/update_gx_data_docs.py#L237">update_gx_data_docs.py</a>.</li></ul><h3>5. Summary</h3><p>Using Great Expectations as part of a tailored data profiling solution for Snowflake offers scalability, automation, and efficiency. This blog post highlights the challenges and details a practical solution for performing bulk data profiling using Great Expectations. Whilst my solution offers a repeatable way to perform bulk data profiling for Snowflake data, be mindful of the time/effort required to get up to speed with concepts/the orchestration flow used by GX.</p><p>Similarly, the generated output should, strictly speaking, use a custom renderer. However, the time/effort spent trying to script the process in a repeatable way meant I couldn’t justify further optimisations.</p><p>In future releases of GX, I’d like to see the OSS documentation greatly improved — as there shouldn’t be a need to refer to legacy documentation. In addition, I think future releases need to make the ability to generate the profiling output a lot more streamlined.</p><p>Happy data profiling!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17776f140cdc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/data-profiling-using-great-expectations-17776f140cdc">Data Profiling Using Great Expectations</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create CI/CD Pipelines for dbt Core]]></title>
            <link>https://medium.com/geekculture/v0-4-pre-chatgpt-how-to-create-ci-cd-pipelines-for-dbt-core-88e68ab506dd?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/88e68ab506dd</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[dbt-core]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Tue, 15 Aug 2023 14:31:51 GMT</pubDate>
            <atom:updated>2023-08-15T16:11:38.085Z</atom:updated>
            <content:encoded><![CDATA[<h4>DBT / How-to</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hc1bBoflqfWn_03ZX8xzmQ.png" /></figure><p><em>This post dives into the use of CI/CD for dbt Core, providing insights on dbt Cloud’s ‘Slim CI’ CICD job pattern and how to implement this using dbt Core. We’ll also touch on other common options available to enhance your dbt CI/CD pipelines.</em></p><h4>Agenda</h4><ol><li>Using CI/CD to Verify Your dbt Changes</li><li>What is the dbt ’Slim CI’ Job Pattern?</li><li>How to Recreate the ‘Slim CI’ Pattern in dbt Core</li><li>Enhancing Your dbt CI/CD Pipeline</li><li>Summary</li><li>Useful Resources</li></ol><h3>1. Using CI/CD to Verify Your dbt Changes</h3><p>In the context of dbt, CI/CD can be used to streamline the testing and deployment processes for files within your dbt project repo.</p><p>For instance, you can ensure the reliability and deployment readiness of your data transformations by triggering a CI/CD pipeline upon code changes, thereby automating the testing of your data models.</p><h3>2. What is the dbt Cloud ‘Slim CI’ Job Pattern?</h3><p>The ‘Slim CI’ job pattern, native to dbt Cloud, is designed to test only modified dbt models when a pull request is created in your dbt Git repository. This is described in detail <a href="https://docs.getdbt.com/docs/deploy/continuous-integration">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xOu7kx1SnMZq2-86.png" /><figcaption>Source: <a href="https://docs.getdbt.com/docs/deploy/continuous-integration">docs.getdbt.com/docs/deploy/continuous-integration</a></figcaption></figure><p>While it’s available in dbt Cloud, this pattern can also be implemented in dbt Core. To achieve this, you can leverage the dbt state:modified and defer functionality. These concepts allow dbt to identify and test only the models that have been changed. This is described further below.</p><h4>What is dbt ‘State’ Processing?</h4><p>We use the state:modified and deferflags to instruct our CI/CD pipeline to only run dbt models that have been modified since the last successful build. Here’s a simple example showing how the state:modified and defer flags can be used within a slim-ci job:</p><pre>version: 2<br>jobs:<br>  dbt_slim_ci:<br>    docker:<br>      - image: your_dbt_image:latest<br>    steps:<br>      - checkout      <br>      - run: dbt deps  # Install dependencies<br>      - run: |<br><br>          OUTPUT=$(dbt ls --selector state:modified+ --defer --state=prod-run-artifacts)  # Get a list of modified dbt models<br>          if [[ -n &quot;$OUTPUT&quot; ]]; then<br>            dbt run --models &quot;$OUTPUT&quot;  # Run dbt only on modified models<br>          else<br>            echo &quot;No modified models found. Skipping dbt run.&quot;<br>          fi</pre><p>In the above code block, we’ve used the dbt state:modified flag in combination with the ls command to list all modified dbt models. We can use the same idea to only run/test modified dbt models, for example, using commands similar to:</p><pre>dbt run --select state:modified+ --defer --state=prod-run-artifacts</pre><p>However, the key detail that is missing in the above is how does dbt determine what models have been modified?</p><h4>How Does dbt Know What Has Been Modified?</h4><p>For dbt to understand the ‘state’ in the above code example, it needs to have access to two versions of the dbt manifest file (i.e., manifest.json):</p><ol><li>One used to describe the dbt project on the main/ masterbranch</li><li>Another to describe the dbt project on the incoming feature branch</li></ol><p>Only if we have two versions of the manifest file can dbt make a comparison to understand/use state processing. Which begs the question, how/where should we put this second manifest file?</p><h4>dbt ‘Defer’</h4><p>As described <a href="https://docs.getdbt.com/reference/node-selection/defer">here</a>, the defer flag is commonly used in combination with state to &quot;enable &#39;Slim CI&#39;&quot;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*2JvS-nbKfPcCer1yD3tKTg.png" /><figcaption>Source: <a href="https://docs.getdbt.com/reference/node-selection/defer">https://docs.getdbt.com/reference/node-selection/defer</a></figcaption></figure><p>In the example in the above screenshot, the defer arg is used to point to/reference a second dbt manifest file. Where it uses this, in combination with the state flag, to understand what dbt models have changed — i.e., enable state processing!</p><h3>3. How to Recreate the ‘Slim CI’ Pattern in dbt Core</h3><p>This section provides a high-level, step-by-step guide to replicating the ‘Slim CI’ pattern in dbt Core using state processing:</p><h4>Step 1: Generate dbt Manifests</h4><p>To create the manifest for your main/master branch, you’ll need to run dbt compile. In addition, as mentioned on <a href="https://docs.getdbt.com/reference/node-selection/defer">dbt&#39;s defer documentation</a>, you&#39;ll need to specify an output location for these &#39;prod run artefacts&#39; using the arg target-path. For example:</p><pre>dbt compile --target-path=prod-run-artifacts</pre><p>dbt commonly gives the example directory name ‘prod-run-artefacts’, but you can use whatever name you wish.</p><h4>Step 2 — Push dbt Manifest</h4><p>We’ll need this manifest.json file to be available within our CI/CD job. As such, it makes sense to push (only) this manifest.json file to your Git main or master branch.</p><h4>Step 3 — Generate Feature Branch Manifest</h4><p>Within your CI/CD job, we’ll need to generate a manifest file for your feature branch as a basis for comparison. For example:</p><pre>version: 2<br>jobs:<br>  dbt_slim_ci:<br>    docker:<br>      - image: your_dbt_image:latest<br>    steps:<br>      - checkout<br>      <br>      - run: |<br>          dbt compile  # Run dbt only on modified models</pre><p>Note: in the dbt compile command used within the CI/CD job, we don&#39;t use the --target-path= arg. That&#39;s only used for the main/master branch.</p><h4>Step 4 — Applying ‘State Processing’</h4><p>Continuing on from the above CI/CD code, we then use the defer and state flags to determine what models have been modified:</p><pre>version: 2<br>jobs:<br>  dbt_slim_ci:<br>    docker:<br>      - image: your_dbt_image:latest<br>    steps:<br>      - checkout  # on our feature branch<br>      <br>      - run: |<br><br>        dbt compile  # compile our feature branch changes<br>        <br>        dbt ls --select state:modified+ --defer --state=prod-run-artifacts  # list the modified dbt models<br>        <br>        dbt run --select state:modified+ --defer --state=prod-run-artifacts  # run modified dbt models only</pre><p>The above code is just a simple example, but you can see why/how two versions of the dbt manifest file are needed for dbt’ state processing’.</p><p>Establishing a dbt ‘slim CI’ job provides an excellent foundation for implementing further CI/CD checks against your dbt project since you’re targeting only modified dbt models to test…rather than an entire dbt project.</p><h3>4. Enhancing Your dbt CI/CD Pipeline</h3><p>I recommend first implementing this dbt’ slim CI’ pattern as the first/foundation of your CI/CD job. Once you have this in place, there are several great next-candidate tests to add. I’ve tried to loosely list these in order of complexity/effort to implement:</p><h4>Candidate 1: SQLFluff</h4><ul><li>A very common approach, it’s even listed <a href="https://docs.getdbt.com/guides/orchestration/set-up-ci/lint-on-push">as an example in dbt’s CI documentation</a>.</li><li>As described in <a href="https://docs.sqlfluff.com/en/stable/production.html#adding-diff-quality-to-your-builds">SQLFluff’s online documentation</a>, to use SQLFluff within CI/CD, you need to use the diff-quality command.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*BiEBMQKBzStmxrB5r42UIQ.png" /><figcaption>Source: <a href="https://docs.sqlfluff.com/en/stable/production.html#adding-diff-quality-to-your-builds">https://docs.sqlfluff.com/en/stable/production.html#adding-diff-quality-to-your-builds</a></figcaption></figure><p>For example:</p><pre>$ diff-quality --violations sqlfluff --compare-branch origin/master --fail-under 100</pre><p>Using diff-quality ensures that SQLFluff lint is only performed on <em>modified </em>dbt models (like Slim CI above).</p><p><strong>Warning: If you’re not currently using SQLFluff, use this with caution</strong></p><p>If SQLFluff isn’t currently used within your team… you’ll need to uplift your existing SQL code to comply with SQLFluff. Otherwise, any SQLFluff linting performed within a CI/CD job will identify SQL linting issues with existing/legacy code.</p><h4>Candidate 2: Git Standards Enforcement</h4><p>Very trivial one (and little effort), I recommend using CI/CD to validate your Git standards. For example, I use CI/CD to validate the Git branch names to ensure it follows our naming conventions. For example:</p><pre># the regex for valid git branch names (i.e., snake_case)<br>VALID_GIT_BRANCH_NAME=&quot;^(feature|hotfix|release)\/[a-z0-9_]+$&quot;<br><br># Validate the Git branch name used<br>if [[ ! $SOURCE_GIT_BRANCH_NAME =~ $VALID_GIT_BRANCH_NAME ]]<br>then<br>    echo<br>    echo -e &quot;${RED}#############################################################################################&quot;<br>    echo -e &quot;${RED}# ERROR: Invalid Git branch name.&quot;<br>    echo -e &quot;${RED}#############################################################################################${COLOUR_OFF}&quot;<br>    echo -e &quot;Local git branch name = $SOURCE_GIT_BRANCH_NAME&quot;<br><br>...<br><br>fi</pre><p>This isn’t the complete code used, but it gives a flavour of what it’s doing.</p><h4>Candidate 3 (High-Value): dbt-checkpoint</h4><p>I strongly recommend using this. <a href="https://github.com/dbt-checkpoint/dbt-checkpoint">dbt-checkpoint</a> provides a variety of pre-commit hooks that can be used within a CI/CD job to verify whether data quality checks have been set (a test to ensure (data quality) tests have been set.)</p><p><strong>Using dbt-checkpoint to Verify DQ Checks Have Been Set</strong></p><p>I won’t digress into the details of Data Quality dimensions, but dbt’s <a href="https://docs.getdbt.com/docs/build/tests#generic-tests">testing features that are shipped ‘out of the box’</a> can be used for many of the <a href="https://www.techtarget.com/searchdatamanagement/definition/data-quality#:~:text=The%20DQAF%20provides%20guidelines%20for,possible%20model%20for%20other%20organizations.">key dimensions of data quality</a>, for example:</p><ul><li>Data Uniqueness, using dbt’s unique test.</li><li>Data Completeness, using not null test.</li><li>Data Validity, using accepted value test.</li><li>Data Timeliness, using dbt ‘freshness’ checks.</li><li>Data Relevance, using dbt’s ‘singular tests’ to implement business rules.</li></ul><p>As such, <a href="https://github.com/dbt-checkpoint/dbt-checkpoint">dbt-checkpoint</a> can be used to ensure the dbt DQ tests have been set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*VYCXZPn6VJPeJhDDJtPDSQ.png" /><figcaption>How dbt-checkpoint can be used to address DQ Dimensions</figcaption></figure><h4>Candidate 4: data-diff</h4><p><a href="https://www.datafold.com/blog/dbt-development-testing-snowflake">data-diff for dbt</a> can be used to compare row counts between two tables, where you&#39;d typically do this by comparing an original table version against a version containing your proposed table revision. To do this, you need to specify the &#39;development&#39; database (and schema) that&#39;s to be used to store your proposed table changes.</p><p>For a good overview of using data-diff with dbt, see <a href="https://www.datafold.com/blog/dbt-development-testing-snowflake">Automate dbt development testing in Snowflake with data-diff | datafold.com</a></p><h3>5. Summary</h3><p>There’s a lot of information listed above, but in summary:</p><ul><li>If you want to use CI/CD against your dbt Core project, I recommend that you first replicate dbt Cloud’s ‘Slim CI’ pattern.</li><li>The above instructions provide a breakdown of the steps required to create this ‘Slim CI’ pattern.</li><li>Only once you’ve created this ‘Slim CI’ job should you investigate further dbt CI/CD checks.</li></ul><h3>6. Useful Resources</h3><p>Listed below are several pertinent articles that’ll put you in good stead when developing CI/CD jobs for dbt Core.</p><ul><li><a href="https://docs.getdbt.com/docs/deploy/slim-ci-jobs">Slim CI jobs in dbt Cloud | dbt Developer Hub</a></li><li><a href="https://docs.getdbt.com/guides/legacy/best-practices">Best practices | dbt Developer Hub</a></li><li><a href="https://docs.getdbt.com/guides/orchestration/custom-cicd-pipelines/1-cicd-background">Customizing CI/CD | dbt Developer Hub</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88e68ab506dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/v0-4-pre-chatgpt-how-to-create-ci-cd-pipelines-for-dbt-core-88e68ab506dd">How to Create CI/CD Pipelines for dbt Core</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating from dbt Cloud to dbt Core — Key Learnings]]></title>
            <link>https://selectfrom.dev/migrating-from-dbt-cloud-to-dbt-core-bfe4ad98e076?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfe4ad98e076</guid>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[dbt-cloud]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Sat, 04 Mar 2023 08:09:31 GMT</pubDate>
            <atom:updated>2023-05-06T02:41:19.515Z</atom:updated>
            <content:encoded><![CDATA[<h4>dbt / Hints and Tips</h4><h4>What are the Benefits &amp; Key Considerations?</h4><p><em>Note: the views described below are my own and don’t represent my employer.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*6i9ATn1vvRmLjxzj8UsZFg.png" /></figure><h4>Agenda</h4><ol><li>Background</li><li>Data Democratization &amp; dbt Cloud</li><li>Proposed Solution for Migrating from dbt Cloud</li><li>dbt Core Install on Windows — Not Plain Sailing</li><li>Summary</li><li>Useful Resources</li></ol><h3>1. Background</h3><p>The licensing cost for dbt Cloud increased across the board in December 2022, with one example being:</p><ul><li>A single seat in a team plan was previously $50/user/month.</li><li>This has doubled to $100/user/month — with an 8-seat limit in the team plan.</li></ul><p>Depending on your team’s number of dbt end-users, this could be a spicy price increase! Though in my team’s example, we had:</p><ul><li>A good baseline understanding of dbt concepts and dbt CLI commands</li><li>A mature/stable dbt project that’s been worked on for over two years</li><li>A desire/need to work towards using our own orchestration.</li></ul><p>With all this in mind, it begged the question, did we still need dbt Cloud? Would dbt core suffice? What would we be missing out on by not using dbt Cloud?</p><h3>2. Data Democratization &amp; dbt Cloud</h3><p>The key arguments for wanting to use dbt Cloud have always been:</p><ul><li>The simplicity of rolling out dbt Cloud — it’s effectively a managed service.</li><li>Data democratization — i.e., allowing self-service access for non-technical end-users to query/use our business data.</li></ul><p>However, the latter point is its biggest downfall. If you don’t have an understanding of common analytics engineering/SDLC practices, should you be able to productionise code?</p><h4>Data Democratization vs Engineering Best Practices</h4><p>dbt Cloud end-users don’t require extensive knowledge of Git — a large part of the Git interaction is handled for them as part of the dbt Cloud UI.</p><p>However, this ‘largely automated’ Git handling process within the dbt Cloud UI highlights the key (accidental) issue introduced by data democratization (highlighted in this example by dbt Cloud) — anyone with access to the dbt Cloud UI can push/productionise code to your git repo?! And consequently, the likelihood of bad habits accidentally being introduced into the code promotion/review process is very high. You, of course, can mitigate this by:</p><ul><li>Putting controls in place from day 1, e.g., implement CICD pipelines on your dbt repo from day 1.</li><li>Coaching/upskilling end-users to ensure they have a baseline understanding of common analytics engineering concepts and considerations.</li></ul><p>But in reality:</p><ul><li>This coaching effort is an ongoing and time-consuming activity.</li><li>Implementing such controls from day 1 infers rolling out CICD pipelines for data is quick — it isn’t! It also infers that there’s a pool of talent readily available to implement such pipelines, which isn’t true.</li></ul><p>As a result, both the coaching/mentoring effort &amp; implementation of CICD controls can fall by the wayside unless adequately nurtured. Since our team were looking towards using our own orchestrator (and, in turn, implementing our own CI/CD pipelines), we really needed to knock some of these bad habits that were accidentally being introduced on the head. And as a result, we went full steam ahead with replacing dbt Cloud with dbt Core. Described below is the migration approach we took and the tooling used.</p><h3>3. Proposed Solution for Migration from dbt Cloud</h3><h4>dbt Core with VSCode dbt Power User Extension</h4><p>To continue to facilitate such non-data engineering type end-user access to dbt, we proposed an alternative solution consisting of the following:</p><ol><li>Rolling out dbt Core with the VSCode dbt Power User extension to provide a similar/like-for-like end-user experience.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*KjazXjFANAkPjlNvAxKrpQ.png" /></figure><p>2. Establishing an Airflow environment, with the view of creating Airflow pipeline equivalents of our dbt Cloud jobs.</p><h4>dbt VSCode Extension — Can Achieve Much of the Same Functionality as to that in dbt Cloud</h4><p>To be honest, it’s quite a good alternative solution as:</p><ul><li>If you’re happy running dbt commands in the IDE terminal like me, you can go ahead and use the terminal.</li><li>However, for those less comfortable, the VSCode extension allows the UI to replicate many visual features provided by dbt Cloud.</li></ul><h4>Git Integration in dbt Cloud vs the Git Interaction in VSCode</h4><p>Many of our analyst team members had little to no knowledge of Git. One of my initial concerns with migrating from Cloud to Core was how much of a learning curve/comfortable some end-users would be interacting with Git. To help mitigate this issue, I provided a quick demo to the team of the Git integration in VSCode, and how this compared to the Git integration in dbt Cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MB4xD0r4jo9U5pJh.png" /><figcaption>Git integration in VSCode</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/0*KpQln7fdn2rkEolb.png" /><figcaption>dbt Cloud IDE, with Git Interaction to the left</figcaption></figure><p>To be honest, the upskilling effort for the analyst end-users has been trivial. If anything, they’ve come across as energized by the learning opportunity. As opposed to git ‘being handled for them’, many of the analysts want to bridge the gap from analyst to data engineer, which benefits absolutely everyone.</p><h3>4. dbt Core Install on Windows — Not as Plain Sailing Compared to Mac/Linux Users</h3><p>Most of our end-users have Windows machines, and dbt Core is designed to be installed in a Linux environment. The workarounds available were to:</p><p>a. Install WSL on end-user machines<br>b. Roll out Docker-based dbt builds<br>c. Set up dbt instance(s), and users remotely log into these</p><ul><li>Option B (using Docker) was ruled out as a result of our end-users, more often than not, being non-engineers.</li><li>Option C introduced broader infra/networking considerations (RBAC, connectivity to our data warehouse, locking down a private dbt instance).</li><li>As such, Option A was the best of a bad bunch.</li></ul><h4>Plain Sailing for Mac Users</h4><p>Whereas the installation for our Mac end-users was plain sailing, the prerequisite installs required on a vanilla WSL Ubuntu install were nowhere near as seamless.</p><p>With that said, the effort required to set up an Ubuntu image on Windows with all of the prerequisite/dbt-core dependent libraries installed is a once-off effort. Once a build script can be established, you can then package &amp; roll this out to the team.</p><h4>dbt Core Enables DataOps &amp; Automation</h4><p>With dbt core now in place, we’ve now been able to:</p><ul><li>Build event-based orchestration pipelines — using Airflow as an orchestrator rather than the cron-based dbt Cloud orchestrator.</li><li>Implement pre-commit hooks to ensure our code quality standards are always adhered to. Some example pre-commit hooks we’re using include <a href="https://sqlfluff.com/">SQLFluff</a>, <a href="https://github.com/slidoapp/dbt-coverage">dbt-coverage</a>, <a href="https://github.com/adrienverge/yamllint">yamllint</a> &amp; many more.</li><li>Enable custom CI/CD pipelines to be developed — we can customize the CICD image built to have the libraries we need for the CICD unit tests we require.</li><li>Enable automation — as a result of having access to the terminal/CLI commands. One key example of this automation — I scripted the dbt core build for our Windows users!</li></ul><h3>5. Summary</h3><h4>dbt Cloud: Good at ‘Getting You Going’, But You’ll Quickly Outgrow It</h4><p>In summary, I’ve spoken to many colleagues who’ve echoed the same sentiment:</p><ul><li>Like many managed services, dbt Cloud is great for quickly rolling out dbt at your organization, as well as onboarding those new to dbt.</li><li>However, after this initial ‘onboarding’ step, the cost of this ‘easy install’ is a very messy codebase. Without extensive controls in place from day one, your codebase will likely be contaminated with code that shouldn’t have been approved.</li><li>Having said that, dbt Cloud can be an attractive offering for organisations with larger budgets, e.g., multinationals looking to get as many of their analysts as close to the data as possible. The only caveat to this is I’d still refrain from allowing such users the ability to productionise their code.</li><li>Migrating from dbt Cloud to Core is more than feasible, where enrolling all of your dbt end-users on the <a href="https://courses.getdbt.com/courses/fundamentals">free dbt fundamentals training</a> goes a long way to making the transition seamless. Just be aware of the required setup effort to create a boilerplate build script to set up dbt Core on Windows, if needed.</li><li>But ultimately, having any WYSIWYG/UI-based orchestration tooling will hold back the development opportunities for your engineers and limit the automation capabilities.</li></ul><h3>6. Useful Resources</h3><p><a href="https://medium.com/paradime-labs/what-does-dbt-cloud-price-increase-mean-8a39c4b7103a">What does dbt-Cloud price increase mean?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfe4ad98e076" width="1" height="1" alt=""><hr><p><a href="https://selectfrom.dev/migrating-from-dbt-cloud-to-dbt-core-bfe4ad98e076">Migrating from dbt Cloud to dbt Core — Key Learnings</a> was originally published in <a href="https://selectfrom.dev/">SelectFrom</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Preparing for the dbt 'Analytics Engineering' Certification]]></title>
            <link>https://medium.com/geekculture/preparing-for-the-dbt-analytics-engineering-certification-5496c3ec6e15?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/5496c3ec6e15</guid>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Wed, 05 Oct 2022 23:57:04 GMT</pubDate>
            <atom:updated>2023-03-29T08:17:50.496Z</atom:updated>
            <content:encoded><![CDATA[<h4>DBT / DBT CERTIFICATION</h4><h4>Hints, tips and advice in preparing for the exam</h4><p>This post aims to provide advice and insights for those working towards the dbt Analytics Engineering certification, the advice I wish I had!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G5nUkZNuA51VRBHE" /><figcaption>Photo by <a href="https://unsplash.com/es/@thoughtcatalog?utm_source=medium&amp;utm_medium=referral">Thought Catalog</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Agenda</strong></h3><ol><li>Exam Overview</li><li>Exam Candidate</li><li>Study Approach and Resources Used</li><li>Certification Review</li></ol><h3>Exam Overview</h3><p>The exam was <a href="https://www.getdbt.com/blog/dbt-certification-program/">first introduced in June 2022</a>, and the high-level exam details are as follows:</p><ul><li>Duration: 2 hours</li><li>Number of questions: 65</li><li>Passing score: 65%</li><li>Price: $200 USD</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hImT0wm638Mq5nPzCT-oMw.png" /><figcaption><a href="https://www.getdbt.com/certifications/analytics-engineer-certification-exam/">dbt Analytics Engineering Certification Exam Overview | getdbt.com</a></figcaption></figure><p>Where the exam consists of questions based on the following topics:</p><ul><li>Developing dbt models</li><li>Debugging data modelling errors</li><li>Monitoring data pipelines</li><li>Implementing dbt tests</li><li>Deploying dbt jobs</li><li>Creating and maintaining dbt documentation</li><li>Promoting code through version control</li><li>Establishing environments in a data warehouse for dbt</li></ul><p>dbt have also provided the <a href="https://www.getdbt.com/assets/uploads/dbt_certificate_study_guide.pdf">following certification study guide</a>.</p><h4>Note: The Exam Doesn&#39;t Exclusively Cover dbt Content</h4><p>When preparing for the exam, remember that the certification is for dbt<strong> ‘</strong><em>Analytics Engineering</em>&#39; rather than a certification exclusively for dbt. As a result (and as indicated by the last two bullet points above), the exam doesn&#39;t solely cover dbt. Key examples of non-dbt topics include:</p><ul><li>Jinja templating</li><li>Git workflows</li><li>SQL, e.g., recommended use of CTEs</li></ul><h3>Exam Candidate</h3><p>On <a href="https://www.getdbt.com/certifications/analytics-engineer-certification-exam/">dbt&#39;s certification webpage</a>, it mentions how the recommended experience of an exam candidate are those with:</p><ul><li>6+ months of building experience on dbt Core or Cloud</li><li>and SQL proficiency</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*DnbTEpiPG2FIAcg5e04Q-A.png" /><figcaption><a href="https://www.getdbt.com/certifications/analytics-engineer-certification-exam/">dbt Analytics Engineering Certification Exam Overview | getdbt.com</a></figcaption></figure><p>However, I recommend candidates have at least one year of hands-on experience. I&#39;ve been using dbt for two years, but importantly have over a year&#39;s experience designing and deploying dbt in production. This is key to understanding implementation patterns and everyday use case considerations, e.g.:</p><ul><li>Options available on how to orchestrate and run dbt jobs in production</li><li>What agreed dbt-Git workflow should you use as a team</li><li>To implement CDC, what <a href="https://docs.getdbt.com/docs/building-a-dbt-project/snapshots#detecting-row-changes">dbt snapshot strategy</a> to use (timestamp vs check)</li><li>Understanding how to manage &#39;<em>hard deletes</em>&#39; with dbt, e.g., being aware of the <a href="https://docs.getdbt.com/reference/resource-configs/invalidate_hard_deletes">invalidate_hard_deletes</a> option</li><li>Understanding the range of dbt tests (and dbt test packages) available and how to store the results using the <a href="https://docs.getdbt.com/reference/resource-configs/store_failures">store_failures</a> option</li></ul><h4>Hands-on Experience Isn&#39;t Enough</h4><p>The more significant point commonly mentioned amongst the <a href="https://www.getdbt.com/community/">dbt slack community</a> is how more than hands-on experience is needed to pass the exam. Instead, candidates should have a firm understanding of supporting dbt reference documentation and other resources described below.</p><h3>Study Approach and Resources Used</h3><p>As a starting point, I naturally went through dbt&#39;s <a href="https://www.getdbt.com/assets/uploads/dbt_certificate_study_guide.pdf">certification study guide</a> as my first port of call.</p><h4>Free Online dbt Training Courses</h4><p>The study guide says to go through dbt&#39;s <a href="https://courses.getdbt.com/collections">(free) online courses</a>. I found these courses all useful, though I recommend the &#39;<a href="https://courses.getdbt.com/courses/fundamentals">dbt fundamentals course</a>&#39; for onboarding developers new to dbt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7qyxakU97T2jc-5akFx-g.png" /><figcaption><a href="https://courses.getdbt.com/collections">dbt&#39;s (free) online training courses | courses.getdbt.com</a></figcaption></figure><h4>First Key Recommendation: Study the dbt Docs, Reference and Guides Documentation</h4><p>I recommend anyone considering sitting the exam first study the official documentation from the dbt website in detail. A common theme on the <a href="https://www.getdbt.com/community/">dbt slack community</a> <em>#dbt-certification</em> channel is how experience isn&#39;t enough and how developers have yet been exposed to much of the dbt functionality. I&#39;d recommend cloning dbt&#39;s <a href="https://github.com/dbt-labs/jaffle_shop">jaffle_shop project</a> and going through dbt&#39;s documentation to replicate the features described.</p><p>The dbt website documentation I found particularly useful was:</p><ul><li><a href="https://docs.getdbt.com/docs/introduction">dbt Docs | getdbt.com</a></li><li><a href="https://docs.getdbt.com/reference/dbt_project.yml">dbt Reference | getdbt.com</a> — I found this section especially useful. In particular, I used this to replicate dbt&#39;s recommended <a href="https://docs.getdbt.com/guides/best-practices/how-we-structure/1-guide-overview">dbt projects structure</a> and create working examples of features described in <a href="https://docs.getdbt.com/blog/essential-dbt-project-checklist">dbt&#39;s project checklist</a>.</li><li><a href="https://docs.getdbt.com/guides/best-practices">dbt Guides | getdbt.com</a> — one particularly useful callout is the &#39;<a href="https://docs.getdbt.com/guides/legacy/debugging-errors">legacy</a>&#39; section. This section deceptively covers two exam topics: &#39;<em>debugging data modelling errors&#39;</em> and &#39;<em>establishing environments in a data warehouse for dbt</em>&#39;. As a result, I&#39;d strongly recommend going through the dbt Guides documentation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O0UwkiQL2B3iVKxtIGqDQg.png" /><figcaption><a href="https://docs.getdbt.com/guides/legacy/debugging-errors">dbt debugging approach on dbt Guides | getdbt.com</a></figcaption></figure><h4>Second Key Recommendation: Become Familiar with dbt Resource Property Configs &amp; Jinja Functions</h4><p>I recommend having a detailed understanding of the different config options available for differing dbt resources (documentation <a href="https://docs.getdbt.com/reference/configs-and-properties">link</a>). A good way of putting it — are you confident of the varying config options available for dbt sources, as shown below? Would you be able to write these from scratch?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*XmBH9MtkfQjWRquCu5ytOw.png" /><figcaption><a href="https://docs.getdbt.com/reference/source-properties">Example of some of the source property config options available</a></figcaption></figure><p><strong>dbt Jinja Functions (</strong><a href="https://docs.getdbt.com/reference/dbt-jinja-functions"><strong>link</strong></a><strong>)</strong></p><p>An array of jinja functions is available in dbt to help make your code DRY. However, I recommend creating your own simple macro to understand what common dbt Jinja functions and variables are available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUoMGxgIyiO7SwGD07qjlg.png" /><figcaption><a href="https://docs.getdbt.com/reference/dbt-jinja-functions">Example of some of the dbt Jinja functions available</a></figcaption></figure><h4>dbt Blog Posts</h4><p>Aside from the training courses, the prep guide lists links to dbt blog posts — where these themes came up in the exam! The blog posts I found particularly useful and pertinent to the exam are as follows:</p><p><strong>Posts Relating to dbt Project Structure</strong></p><ul><li><a href="https://www.getdbt.com/blog/how-we-configure-snowflake/">How we configure Snowflake | getdbt.com</a></li><li><a href="https://docs.getdbt.com/guides/best-practices/how-we-structure/1-guide-overview">How we structure our dbt projects | getdbt.com</a> — note: this was originally a blog post before dbt ported the content to their website. I found it helpful to build the target structure described to understand some decision-making and benefits.</li><li><a href="https://docs.getdbt.com/blog/essential-dbt-project-checklist">Your Essential dbt Project Checklist | getdbt.com</a> — a bit more advanced, but one of the most beneficial, especially when you thoroughly go through it.</li><li><a href="https://www.getdbt.com/blog/five-principles-that-will-keep-your-data-warehouse-organized/">Five principles that will keep your data warehouse organized | getdbt.com</a> — some of the things mentioned closely relate to those mentioned in <a href="https://docs.getdbt.com/guides/best-practices/how-we-structure/1-guide-overview">how we structure our dbt projects</a>. Highlights the emphasis given to these topics.</li></ul><p><strong>Posts Relating to Git Workflows for dbt</strong></p><ul><li><a href="https://www.getdbt.com/blog/how-to-review-an-analytics-pull-request/">How to review an analytics PR | getdbt.com</a> — quite a detailed post, but I found going through this in detail very useful.</li><li><a href="https://docs.getdbt.com/blog/analytics-pull-request-template">The Exact GitHub Pull Request Template We Use at dbt Labs | getdbt.com</a> — actually the opposite of the previous post! In that, it&#39;s a lot quicker to go through.</li></ul><h4>dbt Community on Slack</h4><p>As well as the above, I found the <a href="https://www.getdbt.com/community/">dbt slack community</a> very handy. There is a slack channel dedicated to certification chat called #dbt-certification which is very useful for understanding common themes/questions from others.</p><h4>Note: Knowledge of dbt Cloud isn&#39;t Required</h4><p>One of the common questions asked on the <a href="https://www.getdbt.com/community/">dbt slack community</a> is whether knowledge of dbt Cloud is required for the exam — i.e., will any questions come up relating to dbt Cloud? Looking at the exam curriculum, it&#39;s easy to see why — with section 5 talking about dbt jobs, this sounds like dbt jobs in dbt Cloud, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kf2EKtZSKyxNnv5bLfJUPA.png" /></figure><p>Well, the answer is no! Knowledge of dbt Cloud isn&#39;t required. According to dbt labs staff in the <a href="https://www.getdbt.com/community/">dbt slack community</a>, there are no dbt Cloud-specific questions on the exam. And that <em>&quot;any questions related to jobs should be accessible to anyone who has defined a job, regardless of if it&#39;s in dbt Cloud or a third party orchestration tool.&quot;</em></p><h4>Summary of Recommendations</h4><p>In summary, I recommend exam candidates to:</p><ul><li>Have at least six months of experience, more like one year</li><li>Use dbt&#39;s <a href="https://www.getdbt.com/assets/uploads/dbt_certificate_study_guide.pdf">certification study guide</a></li><li>Work through dbt&#39;s <a href="https://courses.getdbt.com/collections">(free) online courses</a></li><li>Study dbt&#39;s online documentation, particularly the <a href="https://docs.getdbt.com/docs/introduction">docs</a>, <a href="https://docs.getdbt.com/reference/dbt_project.yml">reference</a> and <a href="https://docs.getdbt.com/guides/legacy/debugging-errors">guides</a> sections — writing and executing code examples.</li><li>Have a thorough understanding of <a href="https://docs.getdbt.com/reference/configs-and-properties">dbt resource property options</a> and config and <a href="https://docs.getdbt.com/reference/dbt-jinja-functions">dbt Jinja functions</a>.</li><li>Read the blog posts outlined in the study guide, particularly those listed above.</li></ul><h3>Certification Review</h3><p>The objective of dbt labs in producing the certification is to educate and establish specific standards/patterns in how they would like people to use dbt — I think it has definitely achieved that. Having gone through the above study materials, I&#39;ve regularly revised template scripts I use to follow some of the best practices and naming conventions described. In addition, I found that going through the breadth of documentation highlights lots of really beneficial but potentially not obvious functionality, e.g., the dbt test <a href="https://docs.getdbt.com/reference/resource-configs/store_failures">store_failures</a> option.</p><p>Anyways, I hope some of this information is of use to others. Reach out to me if you have any questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5496c3ec6e15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/preparing-for-the-dbt-analytics-engineering-certification-5496c3ec6e15">Preparing for the dbt &#39;Analytics Engineering&#39; Certification</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Airflow 2: Managed vs Non-Managed Solution?]]></title>
            <link>https://medium.com/geekculture/managed-vs-non-managed-airflow-2-184e7cbb0a3b?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/184e7cbb0a3b</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Mon, 06 Jun 2022 22:21:54 GMT</pubDate>
            <atom:updated>2022-11-18T04:55:15.053Z</atom:updated>
            <content:encoded><![CDATA[<h4>AIRFLOW / BEST PRACTICES</h4><h4>Based on your requirements, which flavour of Airflow should you go for? Astronomer? AWS MWAA? GCP Cloud Composer? Or a self-managed Install?</h4><p><em>Note: the views described below are my own and don&#39;t represent my employer.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJsMPN5kPMI7JuqhsaP7rA.png" /></figure><h4>Agenda</h4><ol><li>Background</li><li>Options Available for Airflow 2 Installation</li><li>Assessment of Options Against Evaluation Criteria</li><li>Summary of the Airflow 2 Options</li><li>Recommendation</li></ol><h3>1. Background</h3><p>Version 1 of Airflow reached End of Life (EOL) in June 2021 and is no longer supported by Airflow (see: <a href="https://airflow.apache.org/docs/apache-airflow/stable/installation/supported-versions.html">Airflow supported versions | airflow.apache.org</a>). As a result, we needed to understand the options available for setting up and installing Airflow 2 based on our current needs and pain points.</p><p>The result — not a straightforward decision! To help aid our selection process, we established our <strong>critical</strong> business criteria for the evaluation after lots of trial and error. This post aims to share our findings to help your decision-making.</p><h3>2. Options Available for Airflow 2 Installation</h3><p>Four options are available for setting up Airflow 2 for a production-grade environment. Where the first three options listed below are managed-service offerings:</p><ol><li>Astronomer: &#39;<em>Any cloud</em>&#39; managed service for Airflow</li><li>AWS MWAA: AWS-managed service for Airflow</li><li>Google Cloud Composer: GCP-managed service for Airflow</li><li>Self-managed Airflow Install</li></ol><p>And the fourth option is to install and configure your Airflow environment on a Kubernetes cluster.</p><h4>Evaluation Criteria</h4><p>As mentioned, establishing the criteria wasn&#39;t straightforward. Each option has pros and cons, and the requirements will be unique to your scenario. However, to help shape the evaluation, we first established our <strong>critical</strong> business criteria for the review. These were as follows:</p><p><strong>Criteria 1: ML workload requirements? </strong>Is the solution capable of supporting Machine Learning/Data Science workloads? Does it need to?</p><p><strong>Criteria 2: Flexibility — </strong>how much can the managed-service offering be customised? What Airflow executor types are available, i.e., are the K8s/CeleryK8s executors available? Are Airflow releases frequently made available?</p><p><strong>Criteria 3: K8s expertise</strong> — how much K8s in-house knowledge do you have to support any potential solution? What is their bandwidth?</p><p><strong>Criteria 4: Value proposition</strong> — what does one Airflow implementation offer that others don&#39;t?</p><p><strong>Criteria 5: Setup effort required</strong> — would the value justify the complexity of the setup needed for the solution?</p><p><strong>Criteria 6: &#39;Local&#39; Development environment</strong> — can a standalone version of the environment be easily configured and installed on a user&#39;s machine?</p><h3>3. Assessment of Options Against Evaluation Criteria</h3><p>So without further ado, let&#39;s see how the four Airflow options stack up against the evaluation criteria.</p><blockquote><strong>Criteria 1: ML Workload requirements? </strong>Is the solution capable of supporting Machine Learning/Data Science workloads? Does it need to?</blockquote><h4>Airflow Executor Types</h4><p>The choice of executor type is critical to the workloads you want to orchestrate using Airflow. Executors significantly impact your task throughput, scalability, and maintenance. The benefits of the different types of Airflow executors are summarised below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*ty0pT0ieiuKllRzm" /></figure><ul><li><strong>Speed of task execution: </strong>the K8sExecutor takes more time since it needs to spin up a pod, assign it to a node, run a docker image, etc. So it may not be the best if you have a lot of small tasks.</li><li><strong>Simplicity: </strong>the LocalExecutor is the simplest one. Very easy to set up and run but doesn&#39;t scale well. The K8sExecutor is more challenging since it relies on Kubernetes.</li><li><strong>Isolation: </strong>the K8sExecutor creates a pod for each task. This avoids dependency conflicts and increases the reliability of the task execution.</li><li><strong>Custom resources: </strong>if you genuinely want to manage your resources, the K8sExecutor is the way to go. You can assign resources (CPU, memory, etc.) to a task according to its specific needs.</li></ul><p>As a result, if you&#39;re looking to use Airflow to orchestrate ML pipelines, you need to use the Kubernetes (or CeleryKubernetes) executor. And as shown below, given they&#39;re the only one offering the availability of the K8s or CeleryK8s executors, only Astronomer or a self-managed Airflow are the only viable options for using Airflow to run MLOps pipelines:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae6b3db960c537bf76119561ec871656/href">https://medium.com/media/ae6b3db960c537bf76119561ec871656/href</a></iframe><blockquote><strong>Criteria 2: Flexibility — </strong>how much can the managed-service offerings be customised? What Airflow executor types are available, i.e., are the K8s/CeleryK8s executors available? Are Airflow releases frequently released?</blockquote><h4>Ability to select the executor type?</h4><p>Shown below is the same table, listing which offerings allow what executor types:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae6b3db960c537bf76119561ec871656/href">https://medium.com/media/ae6b3db960c537bf76119561ec871656/href</a></iframe><p>As you can see, only Astronomer &amp; the self-managed install options allow you to select the type of executor used. As a result, if you&#39;re looking to use Airflow to orchestrate ML pipelines, you&#39;ll need to use either of these two options.</p><p>The very nature of a managed service results in platform engineers having limited options available for configuring installs per their environment requirements.</p><h4>Frequency of Airflow Version Releases</h4><p>The other thing worth noting here is the frequency of releases for the managed service offerings:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/526baed305b17b7bbd36b2b4f0066240/href">https://medium.com/media/526baed305b17b7bbd36b2b4f0066240/href</a></iframe><ul><li>Astronomer is top of the shop here, offering very regular releases</li><li>Cloud Composer offers regular/frequent versions, but not as many as Astronomer.</li><li>AWS MWAA — pretty poor in this department. At the time of writing, it only offers three versions of Airflow as part of its managed service offering: v1.10, 2.02 &amp; 2.2.2</li></ul><p>As you can see, the very nature of a managed service results in limited flexibility in configuring the installation. In contrast, option 4 (self-managed install) provides total flexibility as a non-managed service option.</p><blockquote><strong>Criteria 3: K8s expertise</strong> — how much in-house K8s expertise do you have to support any potential solution? What is their bandwidth?</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/531258f1a60b106e9ddb69d7a839c1a3/href">https://medium.com/media/531258f1a60b106e9ddb69d7a839c1a3/href</a></iframe><p>A bit of a no-brainer; only option 4 requires K8s for the most part. GCP Cloud Composer provides great flexibility in how K8s is deployed for your Airflow cluster. Therefore, it is also (in part) required for option 1.</p><blockquote><strong>Criteria 4: Value proposition</strong> —what does one Airflow implementation offer that others don’t?</blockquote><p><strong>GCP</strong></p><ul><li>If you&#39;re not already using GCP, the value provided by GCP Cloud Composer over the other options isn&#39;t enough to justify the initial GCP account setup required (infra/networking/IAM).</li></ul><p><strong>Astronomer</strong></p><ul><li>&#39;Any cloud&#39; managed solution provides flexibility to pivot the Airflow implementation from one cloud provider to another within the Astronomer ecosystem.</li><li>Astronomer, on paper, seems to be a great candidate, providing similar levels of flexibility. However, enterprise-level support was an essential requirement for our use case, and we required assurances that the service offered in APAC (from overseas resources) would meet our needs. Without testimonials in APAC within multiple industries demonstrating this, we couldn&#39;t entertain this option.</li></ul><p><strong>AWS MWAA</strong></p><ul><li>Remaining within the AWS ecosystem significantly simplifies integration considerations, in particular, secrets and logs management.</li><li>However, the managed AWS Airflow service itself is a compromised solution. See &#39;Criteria 5: Setup effort required&#39; below.</li><li>Furthermore, the Airflow version provided by AWS MWAA doesn&#39;t allow us to develop an Airflow RBAC implementation.</li></ul><p><strong>Self-managed Airflow Install</strong></p><ul><li>A self-managed Airflow 2 environment provides the greatest flexibility required, allowing you to: a) select the executor type required, b) configure bespoke Airflow RBAC roles, and c) install additional libraries on the Airflow instances needed with ease.</li></ul><blockquote><strong>Criteria 5: Setup effort required</strong> — would the value justify the complexity of the required setup for the solution?</blockquote><ul><li><strong>GCP Cloud Composer</strong>: this isn&#39;t a candidate option if you&#39;re not already using GCP. The amount of basic GCP account setup required can&#39;t justify this option.</li><li><strong>Astronomer</strong>: I can&#39;t talk about the setup effort required because this would require a vendor agreement. As a result, a technical spike is needed for this evaluation.</li><li><strong>AWS MWAA</strong>: a poor setup experience, tied in with infrequent releases and a lack of customisation, makes this option only suitable if you&#39;re looking for a quick &#39;no frills&#39; Airflow 2 environment</li><li><strong>Self-managed Airflow</strong>: this could be the best option if you have the K8s expertise available. However, if not, I&#39;d recommend investigating Astronomer further.</li></ul><blockquote><strong>Criteria 6: ‘Local’ Development environment</strong> —can a standalone version of the environment be easily configured and installed on a user’s machine?</blockquote><p>A &#39;local&#39; Airflow development environment can be created for all four options. However:</p><ul><li>AWS MWAA: the local development environment is community-supported (<a href="https://github.com/aws/aws-mwaa-local-runner">GitHub repo link</a>). As such, it&#39;s pretty buggy and prone to errors</li><li>Self-managed Airflow using K8s is possible, but some of the setup and config aren&#39;t trivial. Requires K8s expertise</li></ul><h4>4. Summary of the Airflow 2 Options</h4><h4>Google Cloud Composer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*rHhhL0Lf2aVqHeWB-SrYXg.png" /></figure><ul><li>If you&#39;re not already using GCP as a cloud provider, the Cloud Composer service isn&#39;t a compelling enough reason to switch.</li><li>The effort required to stand up the foundation GCP environment, org setup, IAM, security, networking, etc., doesn&#39;t merit using Cloud Composer.</li><li>It&#39;s a more attractive option than AWS MWAA, but only if you&#39;re already using/within the GCP ecosystem.</li></ul><h4>Astronomer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*JpeF__zlypPXQ5gp67m2ew.png" /></figure><p>Without assurances of the support model &amp; support-level presence in APAC, I couldn&#39;t recommend Astronomer as a candidate for our use case. However, if we were confident about the enterprise-level support, Astronomer becomes a desirable option.</p><h4>AWS MWAA</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*ITGX09vYc5ZMt3Luk8EJRQ.png" /></figure><p>Despite the convenience of an AWS-managed service offering, MWAA feels like a rushed-to-market offering. In particular, concerning the limited/workaround customisations, infrequent releases and poor setup experience. See my previous blog post on the setup experience:</p><p><a href="https://paulfry999.medium.com/review-of-aws-mwaa-i-e-aws-managed-service-for-airflow-fc7d78e7cc15">Review of AWS MWAA and How to Automate the Install</a></p><p>If they can provide more frequent version releases &amp; resolve the executor type limitations &amp; improve their general user guides documentation(!), it would go a long way in making AWS MWAA an attractive proposition.</p><h4>Self-managed Airflow using K8s</h4><p><strong>Pros:</strong></p><ul><li>Complete flexibility to design the Airflow build you need</li><li>Complete flexibility of installation — no limitations, re: what you can &amp; can&#39;t configure</li><li>Cloud-native — Kubernetes itself is a cloud-agnostic technology</li><li>Executor flexibility — no restriction on the choice of executor you wish to use</li></ul><p><strong>Cons:</strong></p><ul><li>Requires you to have platform engineers with K8s expertise (and bandwidth!)</li></ul><p>A self-managed Airflow environment guarantees that the developed environment can be customised and built per your needs. However, this does come with the caveat that this option does require your team to have access to Platform engineers with K8s expertise.</p><h3>5. Recommendation</h3><p>Ultimately, the Airflow managed-service space still has room for improvement:</p><ul><li>Astronomer is a strong contender but needs more of a presence in APAC and greater assurances around its enterprise support model</li><li>If you&#39;re not already a GCP user, Cloud Composer isn&#39;t enough of a compelling reason to move over (I&#39;m not sure you can justify the perquisite cloud networking/security/RBAC required). Especially if you&#39;re already an AWS user, given both offerings limit you to just using the Celery executor</li><li>AWS MWAA is a pretty &#39;no frills&#39; option, more suitable for those who want a basic Airflow install on AWS (to stay on AWS). AWS MWAA needs to offer more flexibility in its solution and more frequent Airflow version releases (i.e., not just v1.10, 2.0.1 &amp; 2.2.2). In addition, AWS MWAA constrains you to only being able to use the celery executor</li></ul><p>If you have Kubernetes expertise in-house, I&#39;d recommend going for the non-managed install. This results in the following:</p><ul><li>Having the design spec you require for your workload</li><li>A non-compromised solution, re: setup and configuration</li><li>A cloud-native solution</li></ul><p>This recommendation comes with two disclaimers:</p><ol><li>You need to have access to K8s expertise. These are typically scarce and in demand, so you also need guarantees about their availability</li><li>Your Kubernetes developers will require some understanding of Airflow concepts to build the K8s cluster (and use the correct executor) you need.</li></ol><p>I hope this all helps. Astronomer could also be a great option on paper, but I&#39;m keen to see/hear about more use cases in APAC.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=184e7cbb0a3b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/managed-vs-non-managed-airflow-2-184e7cbb0a3b">Airflow 2: Managed vs Non-Managed Solution?</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Structure Your DBT Project]]></title>
            <link>https://medium.com/geekculture/how-to-structure-your-dbt-project-c62103deceb4?source=rss-f8e65fb54556------2</link>
            <guid isPermaLink="false">https://medium.com/p/c62103deceb4</guid>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Paul Fry]]></dc:creator>
            <pubDate>Wed, 20 Apr 2022 06:08:24 GMT</pubDate>
            <atom:updated>2022-04-23T13:08:26.831Z</atom:updated>
            <content:encoded><![CDATA[<h4>DBT / BEST PRACTICES</h4><p>This post describes the different approaches for structuring your DBT project(s) and, most importantly, it goes through the steps involved to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bs4QsEzWBpQMfwP2cNfrWw.png" /></figure><h4>Agenda</h4><ol><li>Target audience</li><li>Problems with the default DBT project structure</li><li>Candidate DBT project structures</li><li>Demos/How-to’s</li></ol><ul><li>How to implement the DBT ‘layers’ project structure</li><li>How to reference objects between DBT projects</li><li>How to generate DBT documentation across multiple DBT projects</li></ul><p>5. Summary</p><p>6. Further Reading</p><h3>1. Target audience</h3><p>This post is intended for those with some familiarity with DBT &amp; wish to understand best practices regarding DBT project structure.</p><h3>2. Problems with the default DBT project structure</h3><h4>Unnecessary/redundant query processing</h4><p>When you install DBT by default, you’re using the ‘<strong>monolithic</strong>’ DBT project structure. Doing so can have significant repercussions further down the line when you make changes across your data warehouse. For example, a proposed change can trigger a series of unnecessary queries due to DBT model dependencies. Unless you consistently tag/target objects in your DBT project when running DBT commands, your changes will likely try to run a whole series of queries across your entire data model?!</p><h4>Multiple complex use cases within a single DBT project — poor housekeeping/developer experience</h4><p>It’s more than likely that you have a reasonably mature data warehouse structure that has been built up over time, catering for typical use cases like:</p><ul><li>Source data processing</li><li>Data quality processing</li><li>CDC processing</li><li>Data model transformations</li><li>Data Mart management/presentation layer objects</li></ul><p>As a result, housing all of the transformation logic required to support the above in a single DBT project will likely lead to a poor end-user/developer experience. I.e., you’ll end up with a very congested git repo. An alternative approach is to use <strong>multiple</strong> DBT projects to manage your data warehouse transforms. Described below are some of the options available.</p><h3>3. Candidate DBT project structures</h3><p>How do you want to process and organise your DBT project files? Do you want to build an entire data model each time a change is made? Should you instead create multiple DBT projects for your warehouse transforms? Or group similar logic together within smaller DBT models?</p><p>The image (and project structures described) below come from <a href="https://medium.com/photobox-technology-product-and-design/practical-tips-to-get-the-best-out-of-data-building-tool-dbt-part-1-8cfa21ef97c5">Stefano Solimito’s medium post</a>. However, this post focuses on the steps involved in creating such <strong>non-default</strong> DBT project structure, using the <strong>layered</strong> project structure as an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*crH7Z8nc7iYndFyHfL5Z-w.png" /><figcaption>Source: <a href="https://medium.com/photobox-technology-product-and-design/practical-tips-to-get-the-best-out-of-data-building-tool-dbt-part-1-8cfa21ef97c5">Practical tips to get the best out of Data Build Tool (DBT) | Medium.com</a></figcaption></figure><h4>Default DBT Project Structure: ‘Monolithic’ (Single DBT Project)</h4><p>If you don’t make a design decision around how to structure your DBT project, you’ll default to following the ‘<strong>monolithic</strong>’ structure. In this project structure, you use only a <strong>single</strong> DBT project. Shown below is what the file/folder structure would look similar to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mj1VLN1N6qySdcBh2w1U7A.jpeg" /><figcaption>The default ‘monolithic’ project structure consists of a single DBT project</figcaption></figure><h4>DBT ‘Layers’ Project Structure (Multiple DBT Projects)</h4><p>Tackling the various types of data processing within a single DBT project has its benefits &amp; drawbacks. An alternative approach to having a single, monolithic DBT project is to represent your data landscape is to instead create <strong>multiple</strong> DBT projects. As an example of this approach, shown below is what the file/folder structure would look like for a <strong>layered DBT project:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-VBSI5YOw8sTEGd_ZXmIQ.jpeg" /><figcaption>Using the ‘layered’ project structure, the layer is itself a DBT project</figcaption></figure><p>In this project structure, each ‘layer’ is a <strong>child</strong> DBT project, that are installed as DBT packages against a <strong>parent</strong> project (indicated by &lt;dbt project name&gt; above). Described below is how the folder structure/contents of a layered DBT project structure differentiate from the default <strong>monolithic</strong> project structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tLBKkPH83S2NSQQsyjlMQ.jpeg" /><figcaption>In a layered structure, the DBT projects are installed as <strong>child</strong> projects underneath the data modules folder</figcaption></figure><h4>What about DBT documentation? Can I generate DBT documentation across multiple DBT projects?</h4><p>You can! See ‘<a href="#ed44"><em>how to generate DBT documentation across multiple DBT projects</em></a><em>’</em>.</p><h3>4. Demos/How-to’s</h3><p>Described below are supporting demos/how-to guides to aid using either the ‘layers’, ‘verticals’ or ‘layers and verticals’ project structures.</p><h4>4.1. How to implement the DBT ‘layers’ project structure</h4><p>1. First, create a <strong>parent</strong> dbt project, as per the way you’d usually create a DBT project: dbt init &lt;dbt parent project name, e.g. ‘bike_shop’&gt;</p><p>2. Install all <strong>child</strong> DBT projects by:</p><p>a) Listing all ‘child’ projects within the packages.yml file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*rk26qrB_pBvt5i1ArZ5PUg.png" /><figcaption>DBT ‘child’ projects are installed as DBT packages</figcaption></figure><p>b) And installing these <strong>child</strong> projects by using the DBT CLI command dbt deps</p><p>3. Doing this creates a copy of the DBT files (that you’ve referenced in packages.yml) into the dbt_modules folder, found at the project root:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2NAgfA2BGnAcEQrUQvm7vQ.jpeg" /></figure><p><strong>Note</strong>: you can also install DBT packages (including child projects) from a Git repo. To do so, follow the instructions on DBT’s <a href="https://docs.getdbt.com/docs/building-a-dbt-project/package-management">package management documentation page</a>. The screenshot below highlights what’s required to install either a local or remote DBT package:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*SqSm2tq4y2jMo4FdFRp3mQ.png" /></figure><p>With this in mind, you could <strong>have individual git repos for each DBT project/processing layer.</strong></p><h4>4.2. How to generate <strong>DBT</strong> documentation across multiple dbt projects</h4><p>Because of the DBT <strong>parent-child </strong>project relationship mentioned, it means users can view DBT documentation from both:</p><ul><li>A single DBT project perspective (i.e., a single ‘layer’)</li><li>And also across all DBT projects (layers)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*O1GQCNzeSc9qCLqjKQIBjA.jpeg" /></figure><p>The example above indicates how DBT projects (i.e. layers) can be selected to update the DBT DAG dynamically. Note the greyed out tables; these are from deselected data_quality and snapshot_cdc_processing DBT projects (screenshot below):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*lJcLNjkzogF83uet-Vym3w.jpeg" /></figure><p>To design your DBT project to allow DBT documentation to be generated in this way, do the following:</p><ol><li>First, create a <strong>parent</strong> DBT project: this is what we’ll use to generate our DBT documentation against</li><li>Then create <strong>child</strong> DBT projects for each of your child projects</li><li>Then against the <strong>parent</strong> DBT project, generate your DBT documentation by running: dbt docs &amp;&amp; dbt serve</li><li>And voila! You have a DBT DAG is now showing lineage across all stages of your warehouse!</li></ol><p>Following this approach means you can focus your efforts on the transforms required per-DBT project layer, and not have to worry about how this impacts DBT documentation being generated.</p><h4>4.3. How to reference objects between DBT projects</h4><p>This is a simple one. You need to make use of the DBT ref() function. However, rather than only passing a single arg to the ref function as you usually do, you instead pass two:</p><ol><li>The first to indicate the DBT project (package) you wish to reference</li><li>The second is to specify the object you want to select</li></ol><p>For example:</p><pre>SELECT *</pre><pre>FROM {{ ref(‘<strong>snapshot_cdc_processing</strong>’, ‘<strong>customers_snapshot</strong>’) }}</pre><p>Where snapshot_cdc_processing is another DBT project (package) and customers_snapshot is an object within the project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*g01n7ZeUEkYbk41HzSvxfg.jpeg" /></figure><h3>5. Summary</h3><p>This post aimed to describe how to implement the project structures described in <a href="https://medium.com/photobox-technology-product-and-design/practical-tips-to-get-the-best-out-of-data-building-tool-dbt-part-1-8cfa21ef97c5">Stefano Solimito’s medium post</a>. As well as provide supporting considerations that will help further down the line.</p><p>If you’re new to using DBT, it’s best to start using the default project structure. Though once you’ve gotten to grips with the concepts, I recommend implementing either the ‘layers’, ‘verticals’ or ‘layers and verticals’ DBT project structure, as opposed to the using the default monolithic structure, since:</p><ol><li><strong>Making future changes to your data landscape is seamless</strong></li></ol><ul><li>In comparison to using the monolithic project structure, making future changes to your data landscape is very, very easy when using either the layered, vertical (or ‘layers and verticals’) approaches</li><li>Remove/unpicks a significant amount of dependencies</li></ul><p><strong>2. Avoid unnecessary processing </strong>— you can orchestrate processing to run only against specific layers/verticals</p><p><strong>3. CI/CD integration is much easier</strong></p><ul><li>Tests can be designed and managed within a single project</li><li>With the monolithic structure, all DBT tests would be bundled together in a single project, which is challenging to manage and maintain</li></ul><p><strong>4. Data lineage is a lot more user friendly — </strong>the ability to see lineage per project OR at the parent project level is only possible in these architectures</p><h3>6. Further Reading</h3><p>Just to provide some additional context to the above arguments, see the links below:</p><ul><li><a href="https://discourse.getdbt.com/t/should-i-have-an-organisation-wide-project-a-monorepo-or-should-each-work-flow-have-their-own/666/2">Should I have an organisation wide project (a monorepo) or should each work flow have their own? | discourse.getdbt.com</a></li><li><a href="https://discourse.getdbt.com/t/how-to-configure-your-dbt-repository-one-or-many/2121">How to configure your dbt repository (one or many)? | discourse.getdbt.com</a></li></ul><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c62103deceb4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-structure-your-dbt-project-c62103deceb4">How to Structure Your DBT Project</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>