<?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 Mohamed Dlimi on Medium]]></title>
        <description><![CDATA[Stories by Mohamed Dlimi on Medium]]></description>
        <link>https://medium.com/@mohamed.dlimi.gim?source=rss-71a4731092e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Z1t84BWATyjcwA3f</url>
            <title>Stories by Mohamed Dlimi on Medium</title>
            <link>https://medium.com/@mohamed.dlimi.gim?source=rss-71a4731092e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:09:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohamed.dlimi.gim/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[Snowflake CoCo: The Coding Agent Built for Data]]></title>
            <link>https://medium.com/@mohamed.dlimi.gim/snowflake-coco-the-coding-agent-built-for-data-4c3f1c12cc47?source=rss-71a4731092e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c3f1c12cc47</guid>
            <dc:creator><![CDATA[Mohamed Dlimi]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 15:01:25 GMT</pubDate>
            <atom:updated>2026-06-12T15:01:25.535Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Qu’est-ce que Snowflake CoCo ?</h3><p><strong>Snowflake CoCo</strong> (anciennement <em>Cortex Code</em>) est un agent IA de développement conçu spécialement pour les équipes Data et IA. Contrairement aux assistants de code génériques (Copilot, ChatGPT, etc.), il comprend directement le contexte de l’environnement Snowflake : schémas, tables, permissions, gouvernance, pipelines et métadonnées.</p><h3>🎯 Le problème qu’il résout</h3><p>Les assistants IA classiques génèrent souvent du code correct en apparence, mais sans comprendre :</p><ul><li>les données réelles de l’entreprise,</li><li>les règles d’accès,</li><li>les dépendances entre pipelines,</li><li>les contraintes de gouvernance.</li></ul><p>Résultat : beaucoup de code nécessite encore des corrections avant d’être utilisable en production. CoCo cherche à combler cet écart.</p><h3>🔑 Les nouveautés annoncées</h3><p>Snowflake rend CoCo disponible partout où travaillent les développeurs :</p><ul><li>Application Desktop (Windows et macOS)</li><li>Agent Cloud</li><li>CLI (terminal)</li><li>SDK pour intégrer l’agent dans des workflows personnalisés</li><li>Application mobile (à venir)</li><li>Bot Slack (à venir)</li></ul><h3>⚡ Ce que CoCo permet de faire</h3><p>Avec des instructions en langage naturel, CoCo peut :</p><ul><li>créer des pipelines de données,</li><li>générer du SQL,</li><li>construire des modèles dbt,</li><li>développer des applications et agents IA,</li><li>déboguer des workflows,</li><li>automatiser des tâches Data Engineering,</li><li>accélérer la mise en production.</li></ul><h3>🌐 Au-delà de Snowflake</h3><p>CoCo ne se limite plus à Snowflake. Il peut désormais travailler avec :</p><ul><li>dbt</li><li>Apache Airflow</li><li>Databricks</li><li>AWS Glue</li><li>PostgreSQL</li><li>Spark et d’autres composants du Modern Data Stack.</li></ul><h3>💼 Bénéfices pour les entreprises</h3><p>Selon Snowflake, CoCo permet :</p><ul><li>d’accélérer fortement le développement,</li><li>de réduire les changements de contexte entre outils,</li><li>de respecter automatiquement les règles de gouvernance,</li><li>de passer plus rapidement de l’idée à la production,</li><li>de démocratiser le développement Data même pour des utilisateurs moins techniques.</li></ul><h3>📌 À retenir</h3><p>CoCo est la réponse de Snowflake à la vague des <strong>agents IA de développement</strong>. Sa différence principale est d’être <strong>“data-native”</strong> : il comprend directement les données, la gouvernance et l’architecture de l’entreprise. L’objectif est de devenir l’assistant unique pour construire, gérer et exploiter tout le Modern Data Stack depuis une simple conversation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c3f1c12cc47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Event-Driven Unstructured File Pipeline in Snowflake]]></title>
            <link>https://medium.com/@mohamed.dlimi.gim/building-an-event-driven-unstructured-file-pipeline-in-snowflake-73624c5bfd9c?source=rss-71a4731092e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/73624c5bfd9c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[unstructured-data]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[snowflake-data-ingestion]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Mohamed Dlimi]]></dc:creator>
            <pubDate>Sat, 04 Apr 2026 10:51:00 GMT</pubDate>
            <atom:updated>2026-04-04T10:51:00.828Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Processing unstructured files in Snowflake often starts with a simple question:</p><p><strong>How do you automatically detect new files, parse them, and load the extracted content into tables — without manual intervention?</strong></p><p>When files land in a stage, they don’t automatically become usable data. You still need a mechanism to:</p><ul><li>detect new arrivals</li><li>process them</li><li>and load structured results</li></ul><p>In this article, we’ll build a <strong>fully event-driven pipeline</strong> using:</p><ul><li>a <strong>stage with a directory table</strong></li><li>a <strong>stream</strong></li><li>a <strong>triggered task</strong></li><li>and a <strong>stored procedure</strong></li></ul><p>By the end, you’ll have a <strong>production-ready pattern</strong> that processes files as soon as they arrive.</p><h3>Architecture Overview</h3><p>The pipeline follows a simple flow:</p><p><strong>Files → Stage → Directory Table → Stream → Task → Stored Procedure → Tables</strong></p><ul><li>Files arrive in a stage</li><li>The directory table tracks them</li><li>A stream detects new files</li><li>A task is triggered automatically</li><li>A stored procedure parses and loads the data</li></ul><h3>Step 1 — Create the Stage</h3><p>To work with unstructured data, we start with a stage that has a <strong>directory table enabled</strong>.</p><pre>CREATE OR REPLACE STAGE raw_docs_stage<br>  ENCRYPTION = (TYPE = &#39;SNOWFLAKE_SSE&#39;)<br>  DIRECTORY = (ENABLE = TRUE);</pre><h3>External stage (S3 / GCS / Azure)</h3><pre>CREATE OR REPLACE STAGE raw_docs_stage<br>  URL = &#39;s3://my-bucket/incoming/&#39;<br>  STORAGE_INTEGRATION = my_s3_int<br>  DIRECTORY = (<br>    ENABLE = TRUE<br>    AUTO_REFRESH = TRUE<br>  );</pre><h3>Important</h3><p>If files already exist in the stage, you need to populate metadata:</p><pre>ALTER STAGE raw_docs_stage REFRESH;</pre><h3>Step 2 — Create a Stream on the Stage</h3><p>The stream tracks <strong>new or changed files</strong> in the directory table.</p><pre>CREATE OR REPLACE STREAM raw_docs_stream<br>ON STAGE raw_docs_stage;</pre><p>This is the <strong>event trigger source</strong> for the pipeline.</p><h3>Step 3 — Create Target Tables</h3><p>We typically use:</p><ul><li>a <strong>parsed table</strong> (main output)</li><li>an <strong>audit table</strong> (tracking processing status)</li></ul><pre>CREATE OR REPLACE TABLE parsed_docs (<br>    file_name         STRING,<br>    relative_path     STRING,<br>    file_url          STRING,<br>    extracted_text    STRING,<br>    loaded_at         TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP()<br>);</pre><pre>CREATE OR REPLACE TABLE parsed_docs_audit (<br>    relative_path     STRING,<br>    file_name         STRING,<br>    status            STRING,<br>    message           STRING,<br>    processed_at      TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP()<br>);</pre><h3>Step 4 — Create the Stored Procedure</h3><p>This is the <strong>core of the pipeline</strong>.</p><p>It:</p><ul><li>reads new files from the stream</li><li>builds a scoped URL</li><li>parses each file</li><li>inserts results into tables</li><li>logs success or failure</li></ul><h3>Python Stored Procedure (Recommended)</h3><pre>CREATE OR REPLACE PROCEDURE sp_process_new_files()<br>RETURNS STRING<br>LANGUAGE PYTHON<br>RUNTIME_VERSION = &#39;3.10&#39;<br>PACKAGES = (&#39;snowflake-snowpark-python&#39;)<br>HANDLER = &#39;run&#39;<br>AS<br>$$<br>from snowflake.snowpark import Session<br>def run(session: Session):<br>    stream_sql = &quot;&quot;&quot;<br>        SELECT<br>            RELATIVE_PATH,<br>            FILE_NAME,<br>            FILE_URL<br>        FROM raw_docs_stream<br>        WHERE METADATA$ACTION = &#39;INSERT&#39;<br>          AND RELATIVE_PATH IS NOT NULL<br>    &quot;&quot;&quot;<br>    rows = session.sql(stream_sql).collect()<br>    processed = 0<br>    for r in rows:<br>        relative_path = r[&quot;RELATIVE_PATH&quot;]<br>        file_name = r[&quot;FILE_NAME&quot;]<br>        file_url = r[&quot;FILE_URL&quot;]<br>        try:<br>            scoped_url_sql = f&quot;&quot;&quot;<br>                SELECT BUILD_SCOPED_FILE_URL(@raw_docs_stage, &#39;{relative_path}&#39;)<br>            &quot;&quot;&quot;<br>            scoped_url = session.sql(scoped_url_sql).collect()[0][0]<br>            # --- Parsing logic ---<br>            extracted_text = f&quot;Parsed contents of {file_name}&quot;<br>            session.sql(f&quot;&quot;&quot;<br>                INSERT INTO parsed_docs (<br>                    file_name,<br>                    relative_path,<br>                    file_url,<br>                    extracted_text<br>                )<br>                VALUES (<br>                    &#39;{file_name.replace(&quot;&#39;&quot;, &quot;&#39;&#39;&quot;)}&#39;,<br>                    &#39;{relative_path.replace(&quot;&#39;&quot;, &quot;&#39;&#39;&quot;)}&#39;,<br>                    &#39;{file_url.replace(&quot;&#39;&quot;, &quot;&#39;&#39;&quot;)}&#39;,<br>                    &#39;{extracted_text.replace(&quot;&#39;&quot;, &quot;&#39;&#39;&quot;)}&#39;<br>                )<br>            &quot;&quot;&quot;).collect()<br>            session.sql(f&quot;&quot;&quot;<br>                INSERT INTO parsed_docs_audit (<br>                    relative_path, file_name, status, message<br>                )<br>                VALUES (<br>                    &#39;{relative_path}&#39;,<br>                    &#39;{file_name}&#39;,<br>                    &#39;SUCCESS&#39;,<br>                    &#39;Processed successfully&#39;<br>                )<br>            &quot;&quot;&quot;).collect()<br>            processed += 1<br>        except Exception as e:<br>            session.sql(f&quot;&quot;&quot;<br>                INSERT INTO parsed_docs_audit (<br>                    relative_path, file_name, status, message<br>                )<br>                VALUES (<br>                    &#39;{relative_path}&#39;,<br>                    &#39;{file_name}&#39;,<br>                    &#39;FAILED&#39;,<br>                    &#39;{str(e)}&#39;<br>                )<br>            &quot;&quot;&quot;).collect()<br>    return f&quot;Processed {processed} files&quot;<br>$$;</pre><h3>Step 5 — Create the Triggered Task</h3><p>The task runs <strong>only when new files arrive</strong>.</p><pre>CREATE OR REPLACE TASK task_process_new_files<br>  WAREHOUSE = my_wh<br>  WHEN SYSTEM$STREAM_HAS_DATA(&#39;raw_docs_stream&#39;)<br>AS<br>  CALL sp_process_new_files();</pre><p>Enable it:</p><pre>ALTER TASK task_process_new_files RESUME;</pre><h3>Minimal Working Setup</h3><p>If you just want to test the pipeline quickly:</p><pre>-- Stage<br>CREATE OR REPLACE STAGE raw_docs_stage<br>  ENCRYPTION = (TYPE = &#39;SNOWFLAKE_SSE&#39;)<br>  DIRECTORY = (ENABLE = TRUE);<br>ALTER STAGE raw_docs_stage REFRESH;<br>-- Stream<br>CREATE OR REPLACE STREAM raw_docs_stream<br>ON STAGE raw_docs_stage;<br>-- Table<br>CREATE OR REPLACE TABLE parsed_docs (<br>    file_name STRING,<br>    relative_path STRING,<br>    file_url STRING,<br>    extracted_text STRING<br>);<br>-- Procedure<br>CREATE OR REPLACE PROCEDURE sp_process_new_files()<br>RETURNS STRING<br>LANGUAGE SQL<br>AS<br>$$<br>BEGIN<br>  INSERT INTO parsed_docs<br>  SELECT FILE_NAME, RELATIVE_PATH, FILE_URL, &#39;placeholder&#39;<br>  FROM raw_docs_stream<br>  WHERE METADATA$ACTION = &#39;INSERT&#39;;<br>  RETURN &#39;done&#39;;<br>END;<br>$$;<br>-- Task<br>CREATE OR REPLACE TASK task_process_new_files<br>  WAREHOUSE = my_wh<br>  WHEN SYSTEM$STREAM_HAS_DATA(&#39;raw_docs_stream&#39;)<br>AS<br>  CALL sp_process_new_files();<br>ALTER TASK task_process_new_files RESUME;</pre><h3>How File Parsing Fits Into the Pipeline</h3><p>The parsing logic depends on the file type:</p><ul><li><strong>TXT / JSON / CSV</strong> → direct parsing</li><li><strong>PDF</strong> → Python or Java libraries</li><li><strong>DOCX / images</strong> → parser or OCR</li><li><strong>AI extraction</strong> → Cortex / Document AI / external services</li></ul><h3>Typical flow:</h3><ol><li>Read from stream</li><li>Build scoped URL</li><li>Parse file</li><li>Insert structured data</li><li>Log results</li></ol><h3>Production Best Practices</h3><h3>1. Filter insert events only</h3><pre>WHERE METADATA$ACTION = &#39;INSERT&#39;</pre><h3>2. Avoid duplicates</h3><p>Use MERGE instead of INSERT:</p><pre>MERGE INTO parsed_docs t<br>USING (<br>    SELECT FILE_NAME, RELATIVE_PATH<br>    FROM raw_docs_stream<br>) s<br>ON t.relative_path = s.relative_path<br>WHEN NOT MATCHED THEN INSERT (...);</pre><h3>3. Refresh metadata when needed</h3><pre>ALTER STAGE raw_docs_stage REFRESH;</pre><h3>4. Use a dedicated warehouse</h3><pre>WAREHOUSE = ingestion_wh;</pre><h3>5. Monitor your pipeline</h3><pre>SELECT * FROM DIRECTORY(@raw_docs_stage);<br>SELECT * FROM raw_docs_stream;<br>SELECT * FROM TABLE(INFORMATION_SCHEMA.TASK_HISTORY());</pre><h3>Common Gotchas</h3><h3>1. Task never fires</h3><ul><li>task not resumed</li><li>stream empty</li><li>metadata not refreshed</li></ul><h3>2. Files in stage but not in stream</h3><p>➡️ The stream reads the <strong>directory table</strong>, not storage directly</p><p>Fix:</p><pre>ALTER STAGE raw_docs_stage REFRESH;</pre><h3>3. Procedure runs but parsing fails</h3><p>Check:</p><ul><li>file path</li><li>scoped URL</li><li>parsing library</li></ul><h3>Conclusion</h3><p>This pattern gives you a <strong>clean and scalable way to automate unstructured file ingestion in Snowflake</strong>.</p><p>Instead of relying on batch jobs or manual triggers, you can build a system that reacts <strong>automatically to file arrivals</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73624c5bfd9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loading Data from a DataFrame into Snowflake Using Snowpark (Complete Guide)]]></title>
            <link>https://medium.com/@mohamed.dlimi.gim/loading-data-from-a-dataframe-into-snowflake-using-snowpark-complete-guide-de45517d3c2c?source=rss-71a4731092e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/de45517d3c2c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[snowpark]]></category>
            <dc:creator><![CDATA[Mohamed Dlimi]]></dc:creator>
            <pubDate>Sun, 22 Mar 2026 10:33:08 GMT</pubDate>
            <atom:updated>2026-03-22T10:33:08.825Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In modern data architectures, efficiently loading data into a data warehouse like Snowflake is essential. With <strong>Snowpark</strong>, Snowflake provides a powerful framework that allows developers to work with DataFrames while executing transformations directly inside the Snowflake engine.</p><p>This article explains, step by step, how to load data from a DataFrame into a Snowflake table, with a concrete Python example.</p><h3>Overview of the Process</h3><p>To move data from a DataFrame into a Snowflake table using <strong>Snowpark</strong>, you typically follow this sequence:</p><ol><li><strong>Establish a Snowpark session</strong></li><li><strong>Create or obtain a DataFrame</strong></li><li><strong>Transform data if needed</strong></li><li><strong>Write the DataFrame into a Snowflake table</strong></li><li><strong>Validate the load</strong></li></ol><h3>Step-by-Step Guide</h3><h3>1. Create a Snowpark Session</h3><pre>from snowflake.snowpark import Session<br><br>connection_parameters = {<br>    &quot;account&quot;: &quot;&lt;account&gt;&quot;,<br>    &quot;user&quot;: &quot;&lt;user&gt;&quot;,<br>    &quot;password&quot;: &quot;&lt;password&gt;&quot;,<br>    &quot;role&quot;: &quot;&lt;role&gt;&quot;,<br>    &quot;warehouse&quot;: &quot;&lt;warehouse&gt;&quot;,<br>    &quot;database&quot;: &quot;&lt;database&gt;&quot;,<br>    &quot;schema&quot;: &quot;&lt;schema&gt;&quot;<br>}<br><br>session = Session.builder.configs(connection_parameters).create()</pre><p>This session is the entry point for all Snowpark operations.</p><h3>2. Create a DataFrame</h3><p>You can create a Snowpark DataFrame from:</p><ul><li>Local Python data</li><li>Pandas DataFrame</li><li>Existing Snowflake tables</li></ul><p>Example: Create from local data</p><pre>data = [<br>    (1, &quot;Alice&quot;, 1000),<br>    (2, &quot;Bob&quot;, 1500),<br>    (3, &quot;Charlie&quot;, 2000)<br>]<br><br>columns = [&quot;id&quot;, &quot;name&quot;, &quot;salary&quot;]<br><br>df = session.create_dataframe(data, schema=columns)</pre><h3>3. (Optional) Transform the Data</h3><p>You can apply transformations before loading.</p><p>Snowpark allows transformations similar to Spark or Pandas.</p><pre>from snowflake.snowpark.functions import col<br><br>df_transformed = df.filter(col(&quot;salary&quot;) &gt; 1200)</pre><h3>4. Write DataFrame to a Snowflake Table</h3><p>This is the key step: using write with a save mode.</p><pre>df_transformed.write.mode(&quot;overwrite&quot;).save_as_table(&quot;employees&quot;)</pre><h3>Save Modes Explained</h3><ul><li>&quot;overwrite&quot; → replaces table</li><li>&quot;append&quot; → adds rows</li><li>&quot;errorifexists&quot; → fails if table exists</li><li>&quot;ignore&quot; → skips if table exists</li></ul><h3>5. Validate the Load</h3><pre>session.table(&quot;employees&quot;).show()</pre><p>This ensures that the data has been successfully inserted.</p><h3>Full Working Example</h3><pre>from snowflake.snowpark import Session<br>from snowflake.snowpark.functions import col<br><br># 1. Create session<br>session = Session.builder.configs({<br>    &quot;account&quot;: &quot;&lt;account&gt;&quot;,<br>    &quot;user&quot;: &quot;&lt;user&gt;&quot;,<br>    &quot;password&quot;: &quot;&lt;password&gt;&quot;,<br>    &quot;role&quot;: &quot;&lt;role&gt;&quot;,<br>    &quot;warehouse&quot;: &quot;&lt;warehouse&gt;&quot;,<br>    &quot;database&quot;: &quot;&lt;database&gt;&quot;,<br>    &quot;schema&quot;: &quot;&lt;schema&gt;&quot;<br>}).create()<br><br># 2. Create DataFrame<br>data = [<br>    (1, &quot;Alice&quot;, 1000),<br>    (2, &quot;Bob&quot;, 1500),<br>    (3, &quot;Charlie&quot;, 2000)<br>]<br><br>df = session.create_dataframe(data, schema=[&quot;id&quot;, &quot;name&quot;, &quot;salary&quot;])<br><br># 3. Transform<br>df_filtered = df.filter(col(&quot;salary&quot;) &gt; 1200)<br><br># 4. Load into Snowflake table<br>df_filtered.write.mode(&quot;overwrite&quot;).save_as_table(&quot;employees&quot;)<br><br># 5. Verify<br>session.table(&quot;employees&quot;).show()</pre><h3>Key Tips</h3><ul><li>Snowpark executes transformations <strong>lazily</strong> (nothing runs until an action like save_as_table)</li><li>The table is created automatically if it doesn’t exist (depending on mode)</li><li>You can control schema, partitions, and performance via additional options</li><li>Use append for incremental data pipelines</li><li>Prefer Snowpark transformations over local processing for better performance</li><li>Explicitly manage schemas in production environments</li><li>Monitor Snowflake warehouse usage to control costs</li></ul><h3>Conclusion</h3><p>Using Snowpark simplifies ETL by allowing you to:</p><ul><li>Work with DataFrames like in Spark or Pandas</li><li>Push computation down to Snowflake</li><li>Load data efficiently with minimal code</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de45517d3c2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Snowflake Costs: A FinOps Guide for Data Engineers and Architects]]></title>
            <link>https://medium.com/@mohamed.dlimi.gim/optimizing-snowflake-costs-a-finops-guide-for-data-engineers-and-architects-632a8eb12ac9?source=rss-71a4731092e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/632a8eb12ac9</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[snowflake-architecture]]></category>
            <category><![CDATA[finops]]></category>
            <category><![CDATA[snowflake-cost-management]]></category>
            <dc:creator><![CDATA[Mohamed Dlimi]]></dc:creator>
            <pubDate>Tue, 10 Mar 2026 16:06:54 GMT</pubDate>
            <atom:updated>2026-03-10T16:08:48.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Modern data platforms require elastic compute, scalable storage, and strong cost governance. Snowflake provides these capabilities through a <strong>decoupled architecture</strong> where compute, storage, and services scale independently.</p><p>However, the same elasticity that enables performance can also generate <strong>uncontrolled costs</strong> if workloads are not optimized. This is where FinOps practices become critical.</p><p>This article provides a <strong>technical breakdown of Snowflake pricing mechanics</strong>, how credits are consumed internally, and how engineering teams can apply FinOps practices to optimize cost efficiency.</p><p>Snowflake Architecture Overview</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*uRQ9C1pEFMzbg5hJ7Mq6fg.png" /></figure><p>Snowflake’s architecture is built on <strong>three independent layers</strong>:</p><h3>1. Storage Layer</h3><p>The storage layer manages persistent data stored in cloud object storage such as:</p><ul><li>Amazon Web Services S3</li><li>Microsoft Azure Blob Storage</li><li>Google Cloud Platform Cloud Storage</li></ul><p>Key characteristics:</p><ul><li>Columnar storage format</li><li>Automatic compression</li><li>Micro-partitioning (≈16MB compressed blocks)</li><li>Automatic clustering metadata</li></ul><p>Pricing is charged <strong>per TB stored per month</strong>.</p><p>Storage also includes:</p><ul><li><strong>Time Travel</strong></li><li><strong>Fail-safe retention</strong></li><li><strong>Stage storage</strong></li></ul><h3>2. Compute Layer (Virtual Warehouses)</h3><p>Compute resources are provisioned as <strong>Virtual Warehouses</strong>, which are independent clusters responsible for executing queries.</p><p>Each warehouse:</p><ul><li>Uses dedicated compute resources</li><li>Can auto-scale</li><li>Does not share CPU with other warehouses</li><li>Can run concurrently with others</li></ul><p>Warehouse sizes and credit consumption:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*jKIQa7EEnF_U9eqe1T-lUw.png" /></figure><p>Credits are billed <strong>per second after a 60-second minimum</strong>.</p><p>Key engineering implications:</p><ul><li>Parallel warehouses isolate workloads</li><li>Overprovisioned warehouses waste credits</li><li>Underprovisioned warehouses increase query time</li></ul><h3>3. Cloud Services Layer</h3><p>The Cloud Services layer handles:</p><ul><li>Query parsing</li><li>Query optimization</li><li>Authentication</li><li>Metadata management</li><li>Access control</li><li>Transaction management</li></ul><p>Snowflake usually <strong>does not charge extra</strong> unless cloud service usage exceeds <strong>10% of compute consumption</strong>.</p><h3>Snowflake Pricing Model (Technical Breakdown)</h3><p>Snowflake pricing has <strong>three major cost vectors</strong>:</p><h3>1. Compute (Largest Cost Driver)</h3><p>Credits consumed by warehouses depend on:</p><ul><li>Warehouse size</li><li>Execution duration</li><li>Number of clusters</li><li>Concurrency scaling</li></ul><p>Example:</p><p>Medium warehouse running for <strong>30 minutes</strong>:</p><pre>4 credits/hour × 0.5 hour = 2 credits</pre><p>If credit price = $3:</p><pre>2 × 3 = $6</pre><h3>2. Storage Cost</h3><p>Storage includes:</p><ul><li>Active storage</li><li>Time travel</li><li>Fail-safe</li></ul><p>Typical pricing:</p><pre>~$23–$40 per TB/month</pre><p>Compression usually reduces actual stored size by <strong>3–5x</strong>.</p><h3>3. Data Transfer</h3><p>Charges occur when:</p><ul><li>Data leaves the Snowflake region</li><li>Cross-cloud replication occurs</li><li>External data sharing happens</li></ul><p>Costs depend on the underlying cloud provider.</p><h3>FinOps for Snowflake Engineering Teams</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*6dIwPpj1ljw9fvYXaR3teA.png" /></figure><p>FinOps introduces <strong>continuous cost accountability</strong> between engineering, data, and finance teams.</p><p>Three phases typically drive optimization:</p><h3>1. Inform</h3><p>Goal: <strong>Cost visibility</strong></p><p>Engineers monitor Snowflake usage via system views:</p><pre>SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY<br>SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY<br>SNOWFLAKE.ACCOUNT_USAGE.STORAGE_USAGE</pre><p>Common dashboards track:</p><ul><li>Cost per team</li><li>Cost per warehouse</li><li>Cost per pipeline</li></ul><h3>2. Optimize</h3><p>Engineers reduce credit waste by:</p><h3>Warehouse Right-Sizing</h3><p>Example problem:</p><p>BI dashboards running on <strong>XL warehouses</strong>.</p><p>Solution:</p><p>Move dashboards to <strong>Small warehouses</strong>.</p><p>Savings:</p><pre>XL = 16 credits/hour<br>Small = 2 credits/hour<br>87% cost reduction</pre><h3>Query Optimization</h3><p>High-cost queries often involve:</p><ul><li>Large table scans</li><li>Poor join strategies</li><li>Lack of clustering</li></ul><p>Typical improvements:</p><ul><li>Use <strong>clustering keys</strong></li><li>Avoid SELECT *</li><li>Filter early</li><li>Use result caching</li></ul><h3>Auto Suspend / Auto Resume</h3><p>Idle warehouses often cause <strong>40–60% waste</strong>.</p><p>Best practice:</p><pre>AUTO_SUSPEND = 60 seconds<br>AUTO_RESUME = TRUE</pre><h3>3. Operate</h3><p>Governance mechanisms include:</p><ul><li>Resource monitors</li><li>Budget alerts</li><li>Team chargeback</li></ul><p>Example:</p><pre>CREATE RESOURCE MONITOR finops_monitor<br>WITH CREDIT_QUOTA = 1000<br>TRIGGERS<br>ON 80 PERCENT DO NOTIFY<br>ON 100 PERCENT DO SUSPEND;</pre><h3>Real Snowflake FinOps Optimization Case Study</h3><h3>Scenario</h3><p>A data analytics company runs workloads on Snowflake:</p><ul><li>120 analysts</li><li>15 ETL pipelines</li><li>30 TB data warehouse</li></ul><p>Initial monthly cost:</p><pre>$95,000/month</pre><p>Cost breakdown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*j-2SYPYd9lx9AQ4QFk6rVg.png" /></figure><h3>Problem Analysis</h3><p>Major issues discovered:</p><ol><li>Warehouses left running overnight</li><li>BI dashboards using Large warehouses</li><li>No workload isolation</li><li>Inefficient joins on large tables</li></ol><p>Query history showed:</p><pre>35% warehouse idle time</pre><h3>FinOps Optimization Strategy</h3><h3>Step 1: Warehouse Segmentation</h3><p>Before:</p><pre>1 shared warehouse</pre><p>After:</p><pre>ETL warehouse<br>BI warehouse<br>Data science warehouse</pre><h3>Step 2: Right-Sizing</h3><p>BI warehouse:</p><pre>Large → Small</pre><h3>Step 3: Auto Suspend</h3><p>Set to:</p><pre>60 seconds</pre><h3>Step 4: Query Optimization</h3><p>Actions:</p><ul><li>Added clustering keys</li><li>Materialized aggregated tables</li><li>Reduced full table scans</li></ul><h3>Results</h3><p>After 3 months:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*sO9qO4qmXDU2hema1qQP4g.png" /></figure><p>Savings:</p><pre>≈45% cost reduction</pre><p>Without performance degradation.</p><h3>Key FinOps Best Practices for Snowflake</h3><p>Engineering teams should always:</p><p>✔ Separate warehouses by workload<br> ✔ Enable auto suspend<br> ✔ Monitor credit usage daily<br> ✔ Optimize large queries<br> ✔ Implement resource monitors<br> ✔ Use clustering and caching efficiently</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=632a8eb12ac9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Replica vs Failover in Snowflake: Understanding the Key Differences]]></title>
            <link>https://medium.com/@mohamed.dlimi.gim/replica-vs-failover-in-snowflake-understanding-the-key-differences-03b219c62341?source=rss-71a4731092e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/03b219c62341</guid>
            <category><![CDATA[disaster-recovery]]></category>
            <category><![CDATA[high-availability]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Mohamed Dlimi]]></dc:creator>
            <pubDate>Wed, 04 Mar 2026 23:18:43 GMT</pubDate>
            <atom:updated>2026-03-04T23:18:43.549Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern cloud data platforms, <strong>business continuity</strong> and <strong>disaster recovery</strong> are critical. Snowflake provides powerful cross-region and cross-cloud capabilities to ensure high availability and data protection. Two commonly misunderstood concepts in this context are <strong>Replication (Replica)</strong> and <strong>Failover</strong>.</p><p>Although related, they serve different purposes. This article explains what each one means in Snowflake and how they differ.</p><h3>What Is Replication (Replica) in Snowflake?</h3><p><strong>Replication</strong> in Snowflake refers to the process of copying database objects from a primary account (source) to a secondary account (target), typically in a different region or cloud.</p><h3>Key Characteristics of Replication</h3><ul><li>Creates a <strong>read-only copy</strong> (secondary database)</li><li>Used for:</li><li>Disaster recovery</li><li>Cross-region data sharing</li><li>Business continuity</li><li>Requires manual refresh (or scheduled replication)</li><li>Does <strong>not automatically redirect users</strong></li></ul><p>Replication simply ensures that your data exists in more than one geographic location.</p><h3>How It Works</h3><ol><li>A primary database is created in Region A.</li><li>Replication is enabled to Region B.</li><li>Snowflake copies metadata and data to create a <strong>secondary database</strong>.</li><li>The secondary database remains read-only until promoted.</li></ol><h3>What Is Failover in Snowflake?</h3><p><strong>Failover</strong> is the process of switching from the primary database to the replicated secondary database when the primary becomes unavailable.</p><p>In other words:</p><ul><li>Replication = copying data</li><li>Failover = activating the copy</li></ul><p>Failover is triggered manually (or through orchestration), and it promotes the secondary database to become the new primary.</p><h3>Key Characteristics of Failover</h3><ul><li>Promotes a secondary database to <strong>read-write</strong></li><li>Used during:</li><li>Region outages</li><li>Disaster recovery scenarios</li><li>Redirects workloads to the new active region</li><li>Requires proper role and account configuration</li></ul><p>Failover ensures <strong>continuity of operations</strong>, not just data availability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*EUa4ukQrFevaVBNCqFfFJA.png" /><figcaption>Replica vs Failover: Side-by-Side Comparison</figcaption></figure><h3>Important Concepts in Snowflake Replication &amp; Failover</h3><h3>1. Account-Level Replication</h3><p>Snowflake supports account-level replication across:</p><ul><li>Regions</li><li>Cloud providers (AWS, Azure, GCP)</li></ul><p>This enables multi-cloud disaster recovery.</p><h3>2. Failover Groups</h3><p>Snowflake uses <strong>failover groups</strong> to manage:</p><ul><li>Databases</li><li>Roles</li><li>Warehouses</li><li>Resource monitors</li></ul><p>Failover groups simplify DR orchestration by grouping related objects.</p><h3>Example Scenario</h3><p>Imagine your production environment runs in:</p><ul><li>AWS — US East (Primary)</li></ul><p>You replicate your database to:</p><ul><li>AWS — US West (Secondary)</li></ul><p>If US East experiences an outage:</p><ol><li>You trigger failover.</li><li>The US West replica becomes primary.</li><li>Applications reconnect to the new region.</li><li>Operations continue with minimal downtime.</li></ol><p>Without failover, your replica remains just a backup copy.</p><h3>When Should You Use Replication vs Failover?</h3><h3>Use Replication When:</h3><ul><li>You want disaster recovery readiness</li><li>You need cross-region reporting</li><li>You want backup protection</li></ul><h3>Use Failover When:</h3><ul><li>Your primary region is unavailable</li><li>You need to restore operations immediately</li><li>You are executing a DR test</li></ul><h3>Common Misunderstanding</h3><p>Many people think replication automatically provides high availability. It does not.</p><p>Replication provides <strong>data redundancy</strong>, but failover provides <strong>service continuity</strong>.</p><p>You need both to build a complete disaster recovery strategy in Snowflake.</p><h3>Conclusion</h3><p>In Snowflake:</p><ul><li><strong>Replication</strong> creates a synchronized copy of your data.</li><li><strong>Failover</strong> promotes that copy to take over operations.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03b219c62341" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>