<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matt Arderne</title>
    <description>The latest articles on DEV Community by Matt Arderne (@mattarderne).</description>
    <link>https://dev.to/mattarderne</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F429332%2F5fed0232-a284-45bb-b22a-e5637b843769.jpeg</url>
      <title>DEV Community: Matt Arderne</title>
      <link>https://dev.to/mattarderne</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mattarderne"/>
    <language>en</language>
    <item>
      <title>Snowflake Field Notes</title>
      <dc:creator>Matt Arderne</dc:creator>
      <pubDate>Mon, 13 Jul 2020 10:15:50 +0000</pubDate>
      <link>https://dev.to/mattarderne/snowflake-field-notes-2fdf</link>
      <guid>https://dev.to/mattarderne/snowflake-field-notes-2fdf</guid>
      <description>&lt;p&gt;In &lt;a href="https://groupby1.substack.com/p/data-as-a-utility-tool"&gt;my first post,&lt;/a&gt; I justified an approach to achieve a scalable system for &lt;strong&gt;loading, storing, transforming and distributing&lt;/strong&gt; data within an analytics context. &lt;/p&gt;

&lt;p&gt;In this post, we’ll be taking a look into my notebook on &lt;strong&gt;storing&lt;/strong&gt;. Specifically, the things I’ve noted as useful when implementing Snowflake. These few notes, scripts and points of reference should save you some time and get you out onto the water sooner. &lt;/p&gt;

&lt;p&gt;Welcome to my pocket notebook, heading &lt;em&gt;&lt;strong&gt;Snowflake Important Things - Jan 2020.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;



&lt;h2&gt;
  
  
  Why Snowflake
&lt;/h2&gt;

&lt;p&gt;This isn’t paid content. Though with the flowery praise to come it should be (see contacts below). However, this post doesn't get too far into &lt;em&gt;why&lt;/em&gt; Snowflake. Rather it explores &lt;em&gt;how&lt;/em&gt; Snowflake. Nonetheless, we may need some justification.&lt;/p&gt;

&lt;p&gt;Snowflake’s real value is the &lt;strong&gt;reduction of non-value-adding complexity for the user&lt;/strong&gt;. Putting useful things in your path and keeping anything and everything operationally complex out of your way. Simple as that. If you’ve used PostgreSQL then this shouldn’t feel too foreign, minus index maintenance, table locks, performance issues and upgrades. Pretty standard SQL otherwise, and a few new concepts.&lt;/p&gt;

&lt;p&gt;And you only pay for the capacity and performance you use.&lt;/p&gt;

&lt;p&gt;That’s it really. &lt;/p&gt;

&lt;p&gt;It is &lt;em&gt;just&lt;/em&gt; a SQL database. A very fast one, that handles loads of data, and has lots of usability features. It stores data in a columnar way (rather than rows), which means it is very fast. But you’ll still be writing SQL queries, in a mostly familiar pleasant SQL syntax. &lt;/p&gt;

&lt;p&gt;The primary alternative to Snowflake in this context is Google Bigquery. I’m no expert, but you’d struggle to go wrong with either. Snowflake offers a choice of AWS, Azure or GCP for your horsepower, so that might be reason enough for you to choose Snowflake. At some point, it should start to become clear that Snowflake is just a clever interface for storage and computation built on commodity cloud infrastructure. Very clever. S3 buckets + EC2 for anyone feeling like they’d rather DIY this part, or build a competitor. &lt;/p&gt;

&lt;p&gt;Last part of the intro fanfare: Snowflake is a Data Platform. This is made clear in their recent manoeuvring into the crowded, polluted sea of Data Marketplaces, and a peek into the BI world, with their very simple new Dashboards tool. However, the most platformy move here is a direct integration with Salesforce. More on this in the closing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;This post doesn’t get &lt;em&gt;too far&lt;/em&gt; into the details of the doing, but rather points out things that are somewhat peculiar or unique to Snowflake. Things to be kept in mind when doing the initial deployment. &lt;/p&gt;

&lt;p&gt;The context also caters entirely towards doing your transforming tasks in a SQL transformation tool like &lt;a href="https://dataform.co/?utm_source=groupby1.substack.com"&gt;Dataform&lt;/a&gt; or &lt;a href="https://getdbt.com/?utm_source=groupby1.substack.com"&gt;dbt&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The structure of this post will loosely follow the order in which you’ll encounter and want to consider various new concepts and features as you implement Snowflake. &lt;/p&gt;

&lt;p&gt;We will start with an intro to a Snowflake deployment. We’ll then apply some structure to loading, after getting the security and costs watertight we will finally set sail with some interesting new features and capabilities. &lt;/p&gt;

&lt;h1&gt;
  
  
  1. Deployment
&lt;/h1&gt;

&lt;p&gt;As of publishing this, you can sign up and get started with a free (no credit card), month-long trial, which gets you floating.&lt;/p&gt;

&lt;p&gt;Once you’ve signed up, you’ll need a few things in place as part of the deployment. These include roles, users, databases and warehouses. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lbAknRma--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e6935cff-ff66-4f5c-ae6a-8cee5110c5d9_1600x1067.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lbAknRma--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e6935cff-ff66-4f5c-ae6a-8cee5110c5d9_1600x1067.jpeg" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  New Concepts
&lt;/h2&gt;

&lt;p&gt;The new concepts introduced here are warehouses and credits. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/Warehouses&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Essentially a warehouse is how you specify the &lt;strong&gt;power of compute&lt;/strong&gt; that you use to run queries. This is interesting because you can assign a warehouse to a role. &lt;code&gt;TRANSFORM&lt;/code&gt; roles can use a different warehouse to &lt;code&gt;REPORT&lt;/code&gt; roles. This allows you to fine-tune your compute power and response time for various scenarios. Predictable power for &lt;code&gt;TRANSFORM&lt;/code&gt;, snappy and responsive for &lt;code&gt;REPORT&lt;/code&gt; to keep the end-users happy! &lt;/p&gt;

&lt;p&gt;Warehouses are NOT where you keep your data. Think of a warehouse like a sail that you hoist when the cold query winds blow from the East (or when the warm Summer trade-winds blow from the East depending on your preference).&lt;/p&gt;

&lt;p&gt;Practically, a role is granted privileges to use a warehouse in much the same way a role is granted privileges to access a database. A warehouse also needs to be specified whenever a connection is made to Snowflake. &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grant all privileges on warehouse WAREHOUSE_REPORT 
to role ROLE_REPORT;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;/Credits&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You get billed based on your usage of credits.&lt;/p&gt;

&lt;p&gt;Credits are consumed by storage and warehouses.&lt;/p&gt;

&lt;p&gt;Every time* you start a warehouse, you pay per second in credits, and so credits are effectively your unit of currency. &lt;/p&gt;

&lt;p&gt;At the time of writing a credit is &lt;a href="https://www.snowflake.com/pricing/?utm_source=groupby1.substack.com"&gt;$2-$3&lt;/a&gt;, and negotiating that down when your annual contract value reaches ~$10k is the typical script. &lt;/p&gt;

&lt;p&gt;The outcome of this warehouse/credit scenario is you have &lt;a href="https://www.snowflake.com/blog/understanding-snowflake-utilization-warehouse-profiling/?utm_source=groupby1.substack.com"&gt;a very granular cost breakdown&lt;/a&gt; of your query costs.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;*Not every query starts a warehouse - see cached data section below.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  See a walkthrough of cost calculations, product tiers and implications &lt;a href="https://www.tropos.io/blog/how-to-calculate-your-snowflake-monthly-cost/"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Permissions
&lt;/h2&gt;

&lt;p&gt;This is the &lt;code&gt;grant &amp;lt;PERMISSION&amp;gt; to &amp;lt;ROLE&amp;gt;&lt;/code&gt; part of the database deployment process. &lt;/p&gt;

&lt;p&gt;I like to follow either one of the following two deployment patterns: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;Proof Of Concept&lt;/strong&gt; (POC) keeps things as simple as possible, while still being stable and scalable. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;Production&lt;/strong&gt; option adds some additional structure on top of the POC. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1. Proof of Concept
&lt;/h3&gt;

&lt;p&gt;This setup doesn't distinguish between &lt;code&gt;PROD&lt;/code&gt; and &lt;code&gt;DEV&lt;/code&gt;, and rather relies on branching features later on in the transformation, which is perfectly fine.&lt;/p&gt;

&lt;p&gt;At the core are the 3 roles, with each only having the permissions necessary to function, without the ability to interfere with the other roles’ domains. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;INGEST&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Loads data&lt;/li&gt;
&lt;li&gt;  Can create schemas in &lt;code&gt;RAW&lt;/code&gt; database&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;TRANSFORM&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Creates transformation scripts&lt;/li&gt;
&lt;li&gt;  Can read data in &lt;code&gt;RAW&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Can create schemas in &lt;code&gt;ANALYTICS&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;REPORT&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Read-only access to &lt;code&gt;ANALYTICS&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is shown in the relationship diagram below, where connections indicate permissions assigned. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1svi2s1a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/69161c61-2125-4f33-b112-4517401729ed_1600x675.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1svi2s1a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/69161c61-2125-4f33-b112-4517401729ed_1600x675.png" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;You’ll notice in the diagram that the &lt;code&gt;USER_REPORT&lt;/code&gt; cannot access the &lt;code&gt;RAW&lt;/code&gt; data, this is an entirely deliberate move towards ensuring that downstream tools cannot build a dependency on &lt;code&gt;RAW&lt;/code&gt; data.&lt;/p&gt;

&lt;p&gt;For further clarification on how all this works, I’ve created a starter kit for Snowflake, which creates the above diagram exactly, ready for a POC. If you’re considering a Snowflake implementation, it is well worth an hour to take a look. Pull requests welcome!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://github.com/mattarderne/snowflake-starter"&gt;https://github.com/mattarderne/snowflake-starter&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Production
&lt;/h3&gt;

&lt;p&gt;The following configuration takes the basics from the &lt;strong&gt;Proof Of Concept&lt;/strong&gt; and enhances them to include a more robust separation between &lt;code&gt;PROD&lt;/code&gt; and &lt;code&gt;DEV&lt;/code&gt;. There is a duplication of all entities with &lt;code&gt;_PROD&lt;/code&gt; with a &lt;code&gt;_DEV&lt;/code&gt; version (&lt;code&gt;_DEV&lt;/code&gt; not shown in this diagram for simplicity) and distinct role breakdown for accessing Databases. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_CdU4b81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/71aa7043-46d8-4938-bf05-fa57c2b65b99_1652x1033.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_CdU4b81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/71aa7043-46d8-4938-bf05-fa57c2b65b99_1652x1033.png" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Snowflake case sensitivity is subtly &lt;a href="https://github.com/mattarderne/snowflake-starter/blob/master/utils/case_sensitivity.sql"&gt;different to PostgreSQL&lt;/a&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Unquoted object identifiers are case-insensitive&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;“ANALYTICS” = ANALYTICS = analytics&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a user for every connecting system, and a user for every developer. This will enable you to &lt;strong&gt;track the source and cost of all queries&lt;/strong&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you already have a Snowflake database, you can visually analyse your setup with the &lt;a href="http://snowflakeinspector.hashmapinc.com/?utm_source=groupby1.substack.com"&gt;snowflakeinspector.com&lt;/a&gt;, great for tracking poorly configured snowflake permissions that you may inherit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;A very useful bit of code is the &lt;strong&gt;&lt;code&gt;grant on future&lt;/code&gt;&lt;/strong&gt; snippet, which allows you to grant all future tables in a schema with a certain permission. &lt;/p&gt;

&lt;p&gt;grant usage on future SCHEMAS in database RAW to role TRANSFORM&lt;/p&gt;

&lt;p&gt;grant select on future TABLES in database RAW to role TRANSFORM&lt;/p&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  2. Extract and Load Nuance
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WZNreFqu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/b12d25d5-57a8-45a1-9742-801d66c84d1e_1600x1157.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WZNreFqu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/b12d25d5-57a8-45a1-9742-801d66c84d1e_1600x1157.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/Loaders&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are using &lt;a href="https://stitchdata.com/?utm_source=groupby1.substack.com"&gt;Stitch&lt;/a&gt;, &lt;a href="https://fivetran.com/?utm_source=groupby1.substack.com"&gt;Fivetran&lt;/a&gt; or similar, you can target your data warehouse at this point. Assign the tool the appropriate role, warehouse, database and schema as specified in the deployment script (&lt;code&gt;ROLE_INGEST, WAREHOUSE_INGEST, RAW&lt;/code&gt;). &lt;/p&gt;

&lt;p&gt;Stitch will create a schema based on the name you give to the job, so stick with something scalable. I like &lt;code&gt;&amp;lt;loader&amp;gt;_&amp;lt;source&amp;gt;&lt;/code&gt; format, so you’ll start with something like &lt;code&gt;STITCH_HUBSPOT&lt;/code&gt;. It’s key to note that this means you can later pop out the stitch part for a &lt;code&gt;FIVETRAN_HUBSPOT&lt;/code&gt; or an &lt;code&gt;ETL_HUBSPOT&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/JSON&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Managed ELT tools will load data as best as they can, typically as rows and columns, but often will insert your data as raw JSON into a single column. This is a good thing. It allows you to become familiar with the incredibly useful Snowflake JSON SQL syntax. &lt;/p&gt;

&lt;p&gt;If you write any custom ELT scripts, ensure when loading data to load all data as JSON variant type. This is the crux of ELT. Schemaless loading means your data lands without any notion of a schema, and so you can define the schema later on in one go in the transformation step. This can be seen as a big step, but it helps to be able to define ALL transformations in the transformation stage, and not have to go back to your Python scripts to add new fields.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Start with a tutorial for &lt;a href="https://calogica.com/sql/2018/12/17/parsing-nested-json-snowflake.html/?utm_source=groupby1.substack.com"&gt;handling JSON in Snowflake&lt;/a&gt;, just to get the &lt;a href="https://interworks.com/blog/hcalder/2018/06/19/the-ease-of-working-with-json-in-snowflake/?utm_source=groupby1.substack.com"&gt;basics&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  3. Secure the perimeter
&lt;/h1&gt;

&lt;p&gt;At this stage there is a risk of moving too fast, and that awkward speed wobble is avoided by taking stock and balancing the books.&lt;/p&gt;

&lt;p&gt;The pre-retrospective things to attend to are Costs and Sensitive Data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Costs
&lt;/h2&gt;

&lt;p&gt;Snowflake is a powerful tool, and with the largest warehouse running into the thousands of dollars &lt;em&gt;per hour,&lt;/em&gt; you want to do two things:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/Set a budget and limit&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Determining what you are willing to spend in a month is a good start, and setting a policy to alert you at various increments of that amount will avoid a broadside attack from Finance. Setting the policy to disable future queries across specific warehouses or all of them is a good trip switch to ensure that you aren’t caught at sea.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;/Get alerted *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Worse than running up a large bill (depending on who you ask) would be for your credit limit policy to come into play the moment you click run when demo’ing your fancy analytics to a client or stakeholder. &lt;/p&gt;

&lt;p&gt;For this reason, keeping close tabs on spikes in credit usage and becoming familiar with how and where your credits are going is very high on your new agenda. Remember this is SaaS, i.e. &lt;em&gt;Operational Expense&lt;/em&gt;. &lt;strong&gt;All the costs lay ahead of you on this one.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/snowflakedb/SnowAlert"&gt;SnowAlert&lt;/a&gt; is a tool that Snowflake maintains. I’ve adopted some of the queries as part of my suggested monitoring in the &lt;a href="https://github.com/mattarderne/snowflake-starter/#snowalert"&gt;Snowflake-Starter&lt;/a&gt; repo. The queries look for spending spikes across the infrastructure and will return results only if they detect a spike. &lt;/p&gt;

&lt;p&gt;Last thing on cost management and this is more of an opinion.&lt;/p&gt;

&lt;p&gt;Historically, database resources are specified against a budget for their max expected load. This left lots of performance headroom for the median query. One could view Snowflake costs with some equivalency to this performance headroom, in that a Snowflake query could run faster if you assign it a larger warehouse at increased cost. &lt;/p&gt;

&lt;p&gt;However &lt;strong&gt;there is a premium being paid for the flexibility&lt;/strong&gt;, and so it benefits you to manage your fleet of warehouses carefully, lest they turn on you. Snowflake is an operational expense. This is a subtle shift. The crux is that every credit spent should “deliver value” in a somewhat meaningful way. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Snowflake caches results of queries, meaning that you won’t get charged for queries that hit the cache. This requires some nuance when modelling credit intensive processes like incremental updates. See this &lt;a href="https://medium.com/hashmapinc/30-second-snowflake-cloud-data-warehouse-cheat-sheet-e72c42b863a4"&gt;blog&lt;/a&gt; for a run-through.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Snowflake charges lightly for access to metadata queries, this is because each time your transform tool runs, it queries the schema definition &lt;em&gt;&lt;strong&gt;heavily&lt;/strong&gt;&lt;/em&gt;. This was free, it now isn’t. The cost is negligible but it is worth noting what is going on. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sensitive Data
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;/Masking&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Snowflake’s &lt;strong&gt;“Dynamic Data Masking”&lt;/strong&gt; feature isn’t quite as dynamic as it sounds but is a welcome addition. You’ll &lt;strong&gt;&lt;code&gt;create or replace masking policy EMAIL_MASK&lt;/code&gt;&lt;/strong&gt; and attach that to a role. See this &lt;a href="https://www.youtube.com/watch?v=ByyfTAj97xY"&gt;video&lt;/a&gt; for an explanation. This is a helpful addition to be able to define masks at an object level. This is a new (enterprise only) feature and works in conjunction or in addition to the &lt;a href="https://community.snowflake.com/s/article/Methods-for-Securing-PII-Data-in-Snowflake/?utm_source=groupby1.substack.com"&gt;standard masking features&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/Access Control&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enable a &lt;a href="https://docs.snowflake.com/en/user-guide/network-policies.html"&gt;network policy&lt;/a&gt; that whitelists the IPs of Stitch, your BI tool, VPN etc.&lt;/p&gt;

&lt;p&gt;Enable &lt;a href="https://docs.snowflake.com/en/user-guide/ui-preferences.html#enrolling-in-mfa-multi-factor-authentication"&gt;multi-factor authentication&lt;/a&gt; (MFA) with the &lt;a href="https://duo.com/product/multi-factor-authentication-mfa/duo-mobile-app"&gt;Duo app&lt;/a&gt;. Duo is GREAT. It prompts for a password protected authorisation on your phone’s home screen. No excuses. All users assigned the &lt;code&gt;ACCOUNTADMIN&lt;/code&gt; role should also be required to use MFA.&lt;/p&gt;

&lt;h1&gt;
  
  
  4. Setting Sail
&lt;/h1&gt;

&lt;p&gt;Snowflake at this point, like setting sail, depends on where you want to go. In my &lt;a href="https://groupby1.substack.com/p/data-as-a-utility-tool"&gt;previous post&lt;/a&gt;, I outlined what I’d do next, and it looks something like setting up a few data loading tools, writing transforms in &lt;a href="https://dataform.co/?utm_source=groupby1.substack.com"&gt;Dataform&lt;/a&gt; and then distributing the results in an analytics tool. If you haven’t, &lt;a href="https://groupby1.substack.com/p/data-as-a-utility-tool"&gt;please check it out&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VbrwFry5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/ee90038c-bd14-472b-87f7-301f36998802_1600x1066.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VbrwFry5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/ee90038c-bd14-472b-87f7-301f36998802_1600x1066.jpeg" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I will not be overemphasising this section, but rather point out a few of the most interesting features that fall under &lt;strong&gt;analysing data&lt;/strong&gt;. You could at this point treat Snowflake like you would a very tiny &lt;code&gt;t2.tiny&lt;/code&gt; PostgreSQL instance, forget about it (other than the $) and continue. &lt;/p&gt;

&lt;p&gt;New features in themselves are not always so interesting, but what is interesting is what they enable when combined with existing features. As in technology, so in databases. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/Swap With&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alter database PROD swap with STAGE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Swaps all content and metadata between two specified tables, including any integrity constraints defined for the tables. Also swap all access control privilege grants. &lt;strong&gt;The two tables are essentially renamed in a single transaction&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It also enables a Blue/Green deployment, which in simple terms means: Create a new database with your changes (&lt;code&gt;STAGE&lt;/code&gt;), run tests on that, if they pass, swap it with &lt;code&gt;PROD&lt;/code&gt;. If an hour later you realise you’ve deployed something terrible, swap it back. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/Zero copy clone&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create or replace table USERS_V2 clone USERS
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Create an instant clone of Tables, Schemas, and Databases with zero cost (until you change the data). Great for testing, development and deployment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/Time Travel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Combining the clone function, one can &lt;a href="https://docs.snowflake.com/en/user-guide/data-time-travel.html"&gt;time travel to a table&lt;/a&gt; as it existed at a specified time (1 day back on the standard plan, 90 days on enterprise). The command below will recover the schema at the timestamp (wayward &lt;code&gt;DROP&lt;/code&gt; perchance).&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create schema TEST_RESTORE clone TEST at (timestamp=&amp;gt; to_timestampe(40*365*86400));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;/External functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run a call to a &lt;a href="https://docs.snowflake.com/en/sql-reference/external-functions-introduction.html"&gt;REST API&lt;/a&gt; in your SQL. Great for those pesky ML functions. &lt;/p&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select zipcode_to_city_external_function(ZIPCODE)&lt;br&gt;
from ADDRESS;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Closing Meta Industry Thoughts&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;Snowflake is building a platform, meaning they are building the one-stop-shop for your data needs. The notion of Data Loading is likely going to become more fringe. Snowflake has already moved in this direction with &lt;a href="https://blocksandfiles.com/2020/06/04/snowflake-salesforce-integration-tools/?utm_source=groupby1.substack.com"&gt;Salesforce&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Einstein Analytics Output Connector for Snowflake lets customers move their Salesforce data into the Snowflake data warehouse alongside data from other sources. Joint customers can consolidate all their Salesforce data in Snowflake. Automated data import keeps the Snowflake copy up to date.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This off-the-shelf analytics is a reasonable next step, perhaps in this case due to investment by Salesforce into Snowflake, but that aside, the data space is finding where lie its &lt;em&gt;&lt;strong&gt;layers of abstraction&lt;/strong&gt;&lt;/em&gt;, and this is shown in these industry moves.  &lt;/p&gt;

&lt;p&gt;Snowflake is building a platform, doing it well, and charging you for it. Engineering time remains expensive, and so outsourcing this to Snowflake’s managed platform will be a welcome relief. However there are no free lunches, and Snowflake is building something bigger than a data warehouse. What this means is that if you take too much, you’ll be stuck with too much. &lt;/p&gt;

&lt;p&gt;Echoing &lt;a href="https://www.dremio.com/getting-locked-in-and-locked-out-with-snowflake/?utm_source=groupby1.substack.com"&gt;Dremio&lt;/a&gt;, there is always a thought towards a modular data architecture &lt;em&gt;&lt;strong&gt;“that’s built around an open cloud data lake* (e.g S3) instead of a proprietary data warehouse”&lt;/strong&gt;.&lt;/em&gt; I generally agree with this premise. Snowflake is built on top of AWS or Azure or GCP, and so is (was) a thin layer on top of raw storage and compute. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;* More on &lt;a href="https://fivetran.com/blog/when-to-adopt-a-data-lake//?utm_source=groupby1.substack.com"&gt;data lakes here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Snowflake is marching towards the abstractions seen in Software Engineering, where every job is a feature for them to build. Snowflake has built Data Warehouse Engineer, it is building ETL Engineer &lt;em&gt;and will likely build Data Engineer in some version soon&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3XeszKNR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/cf206714-d7ad-4e9f-a72e-41d12b408620_1600x1068.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3XeszKNR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/cf206714-d7ad-4e9f-a72e-41d12b408620_1600x1068.jpeg" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“It is not the ship so much as the skilful sailing that assures the prosperous voyage.” - George William Curtis&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Please comment if you have any feedback on any of this, I aim to improve with your help.&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;&lt;em&gt;Please consider subscribing for more on the subject of data systems thinking&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://groupby1.substack.com/subscribe?"&gt;&lt;span&gt;Subscribe now&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is &lt;a href="https://groupby1.substack.com/about"&gt;group by 1&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Who is &lt;a href="https://rdrn.dev/?utm_source=groupby1.substack.com"&gt;Matt Arderne&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>datascience</category>
      <category>database</category>
    </item>
    <item>
      <title>Data Architecture as a Utility Tool</title>
      <dc:creator>Matt Arderne</dc:creator>
      <pubDate>Sat, 11 Jul 2020 14:43:04 +0000</pubDate>
      <link>https://dev.to/mattarderne/data-as-a-utility-tool-40oo</link>
      <guid>https://dev.to/mattarderne/data-as-a-utility-tool-40oo</guid>
      <description>&lt;p&gt;&lt;em&gt;Welcome to &lt;strong&gt;&lt;a href="https://groupby1.substack.com/"&gt;group by 1&lt;/a&gt;&lt;/strong&gt;. In this first post, I’ve started broad with my opinion on a few of the typical compromises made when implementing a modern data warehouse solution. Modern meaning cloud, data warehouse meaning the back-end for an analytics tool. This post is a primer for my future content.&lt;/em&gt;&lt;/p&gt;



&lt;p&gt;Within the companies I have worked for and plan on working for, uncertainty is a common thread. Sales &lt;em&gt;may&lt;/em&gt; continue to accelerate, funding &lt;em&gt;should&lt;/em&gt; land next quarter, we &lt;em&gt;hope&lt;/em&gt; to keep in touch. The uncertainty may be more concrete. We &lt;em&gt;should&lt;/em&gt; change to a new CRM. We &lt;em&gt;probably&lt;/em&gt; need to stop reporting in Excel. &lt;/p&gt;

&lt;p&gt;I’ve put together some opinions on what has worked for me in managing uncertainty when architecting data systems that need to cater for many parallel futures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two Buckets
&lt;/h3&gt;

&lt;p&gt;Designing solutions for analytics systems can stylistically or abstractly be described as a problem of two buckets. Bucket one is full of the typical problems a business might have. The business usually then approaches “the data team” with problems such as &lt;strong&gt;help us define a metric / store the data / visualise the KPI / distribute the report&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this simplistic utopia, bucket two, the Solutions Bucket, is typically filled with lots of products and opinions, like &lt;strong&gt;Snowflake / Big Query / my last company used Tableau / group by 1&lt;/strong&gt; etc.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select * from problems_bucket
   inner join (select * from solutions_bucket) 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6kYp2UJM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/465b1ebb-a438-4537-b2e9-3aedf405bcf6_410x259.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6kYp2UJM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/465b1ebb-a438-4537-b2e9-3aedf405bcf6_410x259.png" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The catch when architecting a solution is that you’re &lt;em&gt;&lt;strong&gt;given only one scoop&lt;/strong&gt;&lt;/em&gt; from the solution bucket, with the hope that it covers as many of the items in the problem bucket as possible. The solution bucket is usually very resource-intensive, expensive, time-consuming and gathers momentum once that scoop is moving.&lt;/p&gt;

&lt;p&gt;The decision to re-scoop is not going to be taken lightly. The first scoop usually needs to be made under significant uncertainty and pressure. This is a time to be making bets that will serve you in many of your uncertain futures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Travel Light
&lt;/h3&gt;

&lt;p&gt;For this reason, I invoke the spirit of a prepper, where travelling light is as essential as being prepared. Enter the Swiss army knife.&lt;/p&gt;

&lt;p&gt;My ideal scoop of the solution bucket, like a good utility tool, has a nice healthy mix of scalability, ease of use, and utilitarian functionality. Bare metal that stands the test of time and rests easily on the hip, ready for action!&lt;/p&gt;

&lt;p&gt;More concretely, a lightweight data architecture describes modularity, where each component plays a specified part in the greater whole, without restricting the system. This enables upgrading, downgrading and replacing as necessary. &lt;/p&gt;

&lt;p&gt;With that in mind, I’ll be describing &lt;em&gt;my opinion / experience / preference&lt;/em&gt; for a utilitarian data architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  Context
&lt;/h3&gt;

&lt;p&gt;The context of this article skews heavily to the typical &lt;strong&gt;first-hired-one-person-data-team&lt;/strong&gt; scenario and is generally applicable if that person is within a small business, a startup or a small team within a larger organisation. It can be extended to a data team within a larger organisation that is rethinking their architecture. &lt;/p&gt;

&lt;p&gt;New paradigms start from the ground up, and so it can safely be assumed that this paradigm will be what banks implement in 50 years while the rest of us use quantum computing to think the data into order.&lt;/p&gt;

&lt;p&gt;The driver for this workflow arises from the need to centralise data across multiple systems, typically at the point where there are 3+ key business apps or systems. &lt;/p&gt;

&lt;p&gt;If you're the one called in to take over from the last guy who burnt the ETL (extract-transform-load) candle on both ends and now has a 1000 yard stare, then this might hit a nerve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ingesting, Storing, Transforming, Distributing&lt;/strong&gt;. Four verbs for four (4) sections that describe what will be covered, and the order.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Ingesting
&lt;/h3&gt;

&lt;p&gt;I generally subscribe to the opinion that engineers should avoid writing custom ETL code whenever practically possible, and rather use a managed SaaS ETL tool. This resembles the corkscrew of our Swiss army knife. Powerful and simple.&lt;/p&gt;

&lt;p&gt;Managed ETL tools allow you to connect to your supported sources, point those at your data warehouse and have data flowing in a matter of minutes. You are paying for specialisation here. Post-implementation, the ETL specialist at the end of an intercom is worth their (initially) nominal fee.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9On4w0-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/70020299-3b46-402c-b41e-4de0e3867437_500x333.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9On4w0-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/70020299-3b46-402c-b41e-4de0e3867437_500x333.png" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you cannot get your data into your data warehouse with a managed ETL, or you cannot strike the cost/benefit balance, then you’ll have to start building. This is a great time to think about the possibility of contracting the work to a specialist. They’ll bring the expertise, and over time you can consider internalising that skill as you see fit. Because the work is narrowly described and easily measured, this is a great piece of work for outsourcing. Budget for a maintenance contract, and keep an eye on those Managed ETL services as a replacement option over time.&lt;/p&gt;

&lt;p&gt;Some additional thoughts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ingesting raw data (JSON or tables) into your data warehouse is key. Don’t spend time at this point doing transforms in python, there isn’t time. ETL has been surpassed by ELT (extract-load-transform). This new paradigm is now established.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A Google sheet is a data source. Time is of the essence and done is better than perfect. Data validation, spreadsheet protection and read-only permissions &lt;em&gt;do a database maketh&lt;/em&gt;. Use this one sparingly, as word may get out.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Storing
&lt;/h3&gt;

&lt;p&gt;Balancing the trifecta of scalability, cost and performance is key when picking the backbone of your system. Your data may start small, or large, or small with a risk of growing large. Stopping to change a tire in bear country is never a good look, and neither is a data warehouse migration.&lt;/p&gt;

&lt;p&gt;Managed data warehouses balance the trifecta, with scalability from a team of 1 to 100(n), megabytes to terabytes+, cost starting near zero, and performance flexibility to suit your budget and need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mT8bwlYu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/05e61e78-d226-44c8-a58b-de561533e6c2_5472x3648.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mT8bwlYu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/05e61e78-d226-44c8-a58b-de561533e6c2_5472x3648.jpeg" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Your contract for a data warehouse should begin near $0 and go up from there. Start negotiating your unit costs down once the value of the contract becomes significant, or sooner. The point is that you can get started, prove value, and iron out the details down the line.&lt;/p&gt;

&lt;p&gt;Snowflake is a good start, Big Query does wonders. Microsoft is probably up to something with Azure. Redshift is squarely in the &lt;strong&gt;&lt;code&gt;migrated_from&lt;/code&gt;&lt;/strong&gt; category. All can scale beyond your VC backer's wildest dreams.&lt;/p&gt;

&lt;p&gt;This is the knife of your Swiss army knife, simply put, a knife needs to be sharp, a data warehouse needs to be powerful. The main attraction.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Transforming
&lt;/h3&gt;

&lt;p&gt;Pliers apply leverage. A Swiss army knife doesn’t have pliers, which is why no one owns one, preferring a utility-tool. Loosely applying the same logic, the Transformation Layer has long been the missing link in the analytics stack, with various frustrating attempts at enabling elegant management of transformations. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wra4oAiZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/02752614-89fb-4bc7-9720-ce2329e640b6_6240x4160.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wra4oAiZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/02752614-89fb-4bc7-9720-ce2329e640b6_6240x4160.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The broad goal here is to enable access to your data for your business users while abstracting away as much of the source system complexity as possible. The outcome is clean, documented, coherent, reliable, logical, self-explanatory and performant data that can be relied upon by the &lt;strong&gt;Distributing&lt;/strong&gt; tools. This is the highest leverage point in your pipeline. Leverage that magnifies both gains and mistakes.&lt;/p&gt;

&lt;p&gt;SQL is the language of analysis, and a collection of SQL scripts best describes the transformation of data landed &lt;strong&gt;&lt;code&gt;RAW&lt;/code&gt;&lt;/strong&gt; in your data warehouse to ultimately transformed and ready for &lt;strong&gt;&lt;code&gt;ANALYTICS&lt;/code&gt;&lt;/strong&gt;. The Analytics mentioned here is the schema that you expose to your &lt;strong&gt;Distributing&lt;/strong&gt; tools.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dataform.co/?utm_source=groupby1.substack.com"&gt;Dataform&lt;/a&gt; is a tool that takes that simple concept and runs with it, making writing sophisticated transformations a delight for analysts. Simply explained, Dataform is a SQL editor that enables analysts to build complex transformations in a way that is maintainable and interpretable. Dataform is differentiated by three concepts from software engineering that are put in the hands of the analyst: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1/ Continuous Deployment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A deployment of new code or changes to your transforms should be a thing that happens continuously, and without fear. This is achieved through automated schema tests, continuously deploying code, and data validity and quality tests. This is achieved through the &lt;strong&gt;&lt;code&gt;assertions&lt;/code&gt;&lt;/strong&gt; in Dataform, among other useful features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2/ Version Control&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your job involves writing SQL code, and doesn't involve version control, then perhaps more than anything else, this article was written for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3/ Modularity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your SQL queries typically run into the 100's or 1000's of lines, with sub-queries galore, then breaking that into individual reusable modular components will feel like our man on a rock below. Extend this with JavaScript and suddenly you will be able to &lt;em&gt;truly&lt;/em&gt; &lt;em&gt;express yourself.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tfzJNiM8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/2dc8effc-17e2-494a-9500-e300f9df28fe_6354x4236.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tfzJNiM8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/2dc8effc-17e2-494a-9500-e300f9df28fe_6354x4236.jpeg" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  4. Distributing
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;### TODO - setup a BI tool&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Distribution of data. Commonly described as an Analytics Tool or BI tool aka &lt;em&gt;The Last Mile delivery problem.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In a physical product, and an analytics project, the &lt;strong&gt;last mile of delivery&lt;/strong&gt; is often both the most expensive and time-consuming part of the delivery mechanism. This is the point where the surface area expands massively, and the usage pattern permutations explode. Bluntly; the neatly organised cookie-cutter data pipeline gets punched in the face by the needs of the user.&lt;/p&gt;

&lt;p&gt;The utility-tool analogy falls apart somewhat at this point, as arguably the pliers should be used here. Just like &lt;a href="https://www.leatherman.com/tread-425.html"&gt;this&lt;/a&gt; utility-tool, it can get a bit confusing.&lt;/p&gt;

&lt;p&gt;Broadly speaking the distribution problem gets broken into two categories. BI tools and Analytics Tools. The distinction is murky, like your requirements. Generally speaking, these tools are either:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1/&lt;/strong&gt; Good at solving the operational reporting problems of business: Metrics, KPIs, lots of users, lots of operational complexity (tools like Looker, &lt;a href="https://metabase.com/?utm_source=groupby1.substack.com"&gt;Metabase&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2/&lt;/strong&gt; Good at solving the analysts’ problems: complicated questions, nuanced analysis, vague outcomes, forecasts, predictions (tools like Mode, Periscope, Jupyter Notebooks).&lt;/p&gt;

&lt;p&gt;A rule of thumb is that you need a good few &lt;em&gt;business users&lt;/em&gt; who are comfortable writing complicated SQL or Python before Option 2 will be feasible. This decision is largely based on the operational complexity and technical fluency of the stakeholders in this grand adventure, and generally Option 1 is more broadly applicable.&lt;/p&gt;

&lt;p&gt;If you’ve done good work in your &lt;strong&gt;Transforming&lt;/strong&gt; layer, then you can get away with a compromise here, and use a cheaper tool as a stop-gap, or use an array of tools, or allow the team to choose whatever suits them. Ultimately, you want to trend towards a single source of truth for KPI / Metric type numbers, and aim to automate their delivery.&lt;/p&gt;

&lt;h3&gt;
  
  
  My experience
&lt;/h3&gt;

&lt;p&gt;I've honed in on my preferred data stack, described below. This stack is likely a feasible option for your goals if they are related to aligning your business on key metrics. Especially so if you have multiple SaaS or custom software systems floating around that drive these metrics. What you’ll end up with is something like the following diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--atVNghq3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e0996748-9c20-4b96-a212-264c33e4ca9e_1600x1004.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--atVNghq3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e0996748-9c20-4b96-a212-264c33e4ca9e_1600x1004.png" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ingesting/&lt;/strong&gt; As mentioned, I prefer to use a SaaS ELT tool like &lt;a href="https://www.stitchdata.com/?utm_source=groupby1.substack.com"&gt;Stitch&lt;/a&gt; or &lt;a href="https://www.fivetran.com/?utm_source=groupby1.substack.com"&gt;Fivetran&lt;/a&gt;, as they reduce the need for ongoing maintenance where possible. Stitch is the cheaper option, and a great low-cost starting point, with the following useful additions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It has a great &lt;a href="https://www.stitchdata.com/integrations/import-api/?utm_source=groupby1.substack.com"&gt;Import API&lt;/a&gt; that allows some simplification of ELT scripts if you do need to write them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has a useful &lt;a href="https://www.stitchdata.com/integrations/google-sheets/?utm_source=groupby1.substack.com"&gt;Google Sheets&lt;/a&gt; Integration, as well as the usual Postgres, Hubspot, Salesforce, Google/Facebook ads etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Storing/&lt;/strong&gt; The stack described orients towards &lt;a href="https://cloud.google.com/bigquery/?utm_source=groupby1.substack.com"&gt;BigQuery&lt;/a&gt; or &lt;a href="https://snowflake.com/?utm_source=groupby1.substack.com"&gt;Snowflake&lt;/a&gt;, with PostgreSQL also a feasible option. I prefer the scale / cost model of Snowflake.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Snowflake scales up to enterprise but starts from $2/credit, so can be a very cost-effective bet with typical small loads running around 2-5 credits per day. This can get very expensive if you don’t manage it carefully with limits.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PostgreSQL will require a migration in the future, so unless you are very cost sensitive, the cost / benefit generally leans in favour of Snowflake.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I have a &lt;a href="https://github.com/mattarderne/snowflake_init/blob/master/first_run.sql"&gt;simple SQL script&lt;/a&gt; used to setup Snowflake ready to use for a POC, and I like to use &lt;a href="https://github.com/snowflakedb/SnowAlert/blob/master/packs/snowflake_query_pack.sql"&gt;these&lt;/a&gt; &lt;a href="https://github.com/snowflakedb/SnowAlert/blob/master/packs/snowflake_cost_management.sql"&gt;scripts&lt;/a&gt; to track Snowflake credit usage in combination with Dataform assertions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Distributing/&lt;/strong&gt; This is where business users will interact with and judge the success of your system, so to spend your budget on the rest of the components but cut corners on the distribution tool is a bad idea. That said, BI tools can have expensive annual contracts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://metabase.com/?utm_source=groupby1.substack.com"&gt;Metabase&lt;/a&gt; is a great open-source BI tool and should give you a good place to start. The cost jump is quite severe up to &lt;a href="https://looker.com/?utm_source=groupby1.substack.com"&gt;Looker&lt;/a&gt; / &lt;a href="https://chartio.com/?utm_source=groupby1.substack.com"&gt;ChartIO&lt;/a&gt;, but so is the feature set.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These tools are trickier to migrate from, and so it is reasonable to expect to be locked-in for the mid-term.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Transforming/&lt;/strong&gt; This may be premature depending on the level of sophistication of logical transformations required to answer your questions, but at some stage it will make sense to move your transforms to the data warehouse from the BI tool. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The best of breed at this stage is &lt;a href="https://dataform.co/?utm_source=groupby1.substack.com"&gt;Dataform&lt;/a&gt; or &lt;a href="https://www.getdbt.com/?utm_source=groupby1.substack.com"&gt;dbt.&lt;/a&gt; These tools enable software development best practices (git, testing, documentation).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There is relatively little involved in adding this from the start, and significant gains to be had if used to build a logical data model from the start.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I have deployed Metabase successfully with https and nice scalability using &lt;a href="https://github.com/mattarderne/metabase"&gt;these Docker scripts&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In future editions I’ll be diving into the above specifics, stay tuned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Taking the time to properly implement a reasoned and scalable analytics infrastructure is an axe sharpening exercise with benefits that may compound massively over time. Second-order benefits to aim for include increasing the data proficiency of your team, enabling evidence-based decision making and most importantly, increasing alignment.&lt;/p&gt;

&lt;p&gt;Most businesses follow similar patterns, and in survival as in business, preparation is key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OBZP_Eqs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/ccaa6be0-683a-4961-abe6-abec07d6018b_1600x1068.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OBZP_Eqs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/ccaa6be0-683a-4961-abe6-abec07d6018b_1600x1068.jpeg" alt="https://images.unsplash.com/photo-1545476745-9211a9e7cca8?ixlib=rb-1.2.1&amp;amp;q=85&amp;amp;fm=jpg&amp;amp;crop=entropy&amp;amp;cs=srgb"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Give me six hours to chop down a tree and I will spend the first four sharpening the axe.” - Abe&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;&lt;em&gt;Please consider subscribing for more on the subject of data systems thinking&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://groupby1.substack.com/subscribe?"&gt;&lt;span&gt;Subscribe now&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is &lt;a href="https://groupby1.substack.com/about"&gt;group by 1&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Who is &lt;a href="https://rdrn.dev/?utm_source=groupby1.substack.com"&gt;Matt Arderne&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>datascience</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
