<?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 Pierre-Mickaël Chancrin on Medium]]></title>
        <description><![CDATA[Stories by Pierre-Mickaël Chancrin on Medium]]></description>
        <link>https://medium.com/@pmchancrin?source=rss-ed362bfad050------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SInxp2dQca_HbHqr.jpg</url>
            <title>Stories by Pierre-Mickaël Chancrin on Medium</title>
            <link>https://medium.com/@pmchancrin?source=rss-ed362bfad050------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 18:29:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pmchancrin/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[️ Feedback — Whistle Alerts & Snowflake Warehouse Performance]]></title>
            <link>https://medium.com/@pmchancrin/%EF%B8%8F-feedback-whistle-alerts-snowflake-warehouse-performance-4ee34f624a7e?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ee34f624a7e</guid>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Thu, 11 Jun 2026 07:11:00 GMT</pubDate>
            <atom:updated>2026-06-11T07:11:00.682Z</atom:updated>
            <content:encoded><![CDATA[<p>Following the monitoring alerts received through Sifflet Data, I ran all the quality checks provided by the platform. Since the results came back clean, I decided to investigate the performance of the associated Snowflake warehouse in more detail.</p><p>By running the following query:</p><pre>SELECT<br>    warehouse_name,<br>    AVG(avg_running) AS avg_running_queries,<br>    AVG(avg_queued)  AS avg_queued_queries<br>FROM snowflake.account_usage.query_history<br>WHERE warehouse_name = &#39;SIFFLET_WH&#39;<br>  AND start_time &gt;= DATEADD(hour, -24, CURRENT_TIMESTAMP())<br>GROUP BY warehouse_name;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*dUIVSEuPS9mnCkPM" /></figure><p>I was able to identify the root cause: ➡️ the warehouse was undersized for the actual workload.</p><p>🧩 <strong>In summary (Snowflake golden rule)</strong></p><ul><li><strong>CPU queue → scale‑up</strong></li><li><strong>Concurrency queue → scale‑out</strong></li></ul><p>From the Query History view, here’s what stands out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Sc_qko2AM6KS4sl7" /></figure><ul><li><strong>avg_queued_queries &gt; 0 → scale‑out</strong></li><li><strong>High avg_running_queries but no queue → scale‑up</strong></li></ul><p>After adjusting the warehouse scaling, workloads stabilized and no further alerts were triggered.</p><p>📊 <strong>Objective reading of SIFFLET_WH</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*bK3yYpiAFwkciLf8Gyn1pA.png" /></figure><p>🎯 <strong>Clear diagnosis</strong></p><p>🔺 <strong>Scale‑UP required</strong></p><ul><li>AVG_QUEUED_LOAD clearly &gt; 0</li><li>Very few concurrent queries (AVG_RUNNING ≈ 1.3)</li><li>No blocking</li></ul><p>➡️ The warehouse lacks per‑query compute power — not parallelism.</p><p>❌ <strong>Why scale‑OUT would be the wrong choice</strong></p><ul><li>Concurrency is low</li><li>Multi‑cluster provisioning is almost zero</li><li>Adding clusters won’t reduce CPU queueing</li></ul><p>➡️ Scale‑out would increase cost with no benefit.</p><p>✅ <strong>Recommended action</strong></p><p><strong>Best option:</strong> Increase the warehouse size, e.g.:</p><ul><li>SMALL → MEDIUM</li><li>MEDIUM → LARGE</li></ul><p><strong>Expected outcome:</strong></p><ul><li>AVG_QUEUED_LOAD disappears</li><li>More stable query times</li><li>Controlled cost (fewer retries / queues)</li></ul><p>🧠 <strong>Golden rule validated by your metrics:</strong> <strong>CPU queue + low concurrency = SCALE‑UP</strong></p><p>Enjoy with Snowflake ;)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PED7zVzGuvRSWJQvMNUn7Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ee34f624a7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy Snowflake DCM]]></title>
            <link>https://medium.com/@pmchancrin/how-to-deploy-snowflake-dcm-9ba7f8b017f7?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ba7f8b017f7</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Fri, 05 Jun 2026 17:47:42 GMT</pubDate>
            <atom:updated>2026-06-10T07:07:31.516Z</atom:updated>
            <content:encoded><![CDATA[<p>The DCM (Database Configuration Management) Proof of Concept aims to demonstrate how Snowflake allows managing all platform objects in a declarative, versioned, and reproducible manner, similar to what Terraform provides for cloud infrastructure.</p><p>This POC illustrates DCM’s ability to automate the creation, modification, and governance of Snowflake objects (databases, schemas, tables, warehouses, roles, grants…) while ensuring complete consistency across DEV, TEST, and PROD environments.</p><p>Thanks to a GitOps approach, every change becomes traceable, auditable, and deployable via a simple PLAN and then DEPLOY.</p><p>This POC provides a solid foundation for industrializing Snowflake deployments, reducing the risk of human error, and accelerating the deployment of data changes to production.</p><p>For this demo, i used Cortex Code !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UkYRggkWdRJPS5w9_va3zg.png" /></figure><h3>🎯 Objective</h3><p>Create a simple DCM Project that deploys:</p><pre>1 database<br>1 schema<br>1 table<br>1 view<br>1 warehouse<br>1 role + grants</pre><p>Everything declarative, reproducible, versioned, and compatible with multiple environments (DEV / PROD).</p><h3>📁 Project DCM Structure</h3><p>A DCM project CANNOT define its own parent database or schema. To work around this, the project object lives in a dedicated admin schema (DCM_ADMIN.PROJECTS) that is separate from the objects it manages (POC_DCM_DEV / POC_DCM_PROD).</p><p>The admin schema must exist before the project is created. The managed databases and schemas are defined by the project itself.</p><pre>poc-dcm/<br>├── manifest.yml<br>└── sources/<br>    └── definitions/<br>        ├── infrastructure.sql<br>        ├── tables.sql<br>        ├── views.sql<br>        └── access.sql</pre><h3>🧩 1. manifest.yml</h3><pre>manifest_version: 2<br>type: DCM_PROJECT<br>default_target: &#39;DEV&#39;<br><br>targets:<br>  DEV:<br>    account_identifier: &lt;Account_identifier&gt; -- replace with your snowfake account<br>    project_name: &#39;DCM_ADMIN.PROJECTS.POC_DCM_PROJECT_DEV&#39;<br>    project_owner: &lt;role&gt; -- replace with your snowfake role<br>    templating_config: &#39;DEV&#39;<br>  PROD:<br>    account_identifier: &lt;Account_identifier&gt; -- replace with your snowfake account<br>    project_name: &#39;DCM_ADMIN.PROJECTS.POC_DCM_PROJECT_PROD&#39;<br>    project_owner: &lt;role&gt; -- replace with your snowfake role<br>    templating_config: &#39;PROD&#39;<br><br>templating:<br>  defaults:<br>    env: &#39;DEV&#39;<br>    db_name: &#39;POC_DCM_DEV&#39;<br>    schema_name: &#39;CORE&#39;<br>    warehouse_name: &#39;WH_POC_DCM_DEV&#39;<br>    role_name: &#39;ROLE_POC_DCM_DEV&#39;<br>    wh_size: &#39;XSMALL&#39;<br>  configurations:<br>    DEV:<br>      env: &#39;DEV&#39;<br>      db_name: &#39;POC_DCM_DEV&#39;<br>      warehouse_name: &#39;WH_POC_DCM_DEV&#39;<br>      role_name: &#39;ROLE_POC_DCM_DEV&#39;<br>      wh_size: &#39;XSMALL&#39;<br>    PROD:<br>      env: &#39;PROD&#39;<br>      db_name: &#39;POC_DCM_PROD&#39;<br>      warehouse_name: &#39;WH_POC_DCM_PROD&#39;<br>      role_name: &#39;ROLE_POC_DCM_PROD&#39;<br>      wh_size: &#39;SMALL&#39;</pre><h3>🧩 2. Definition files</h3><pre>&gt;&gt; sources/definitions/infrastructure.sql<br><br>DEFINE DATABASE {{ db_name }};<br><br>DEFINE SCHEMA {{ db_name }}.{{ schema_name }};<br><br>DEFINE WAREHOUSE {{ warehouse_name }}<br>WITH WAREHOUSE_SIZE = &#39;{{ wh_size }}&#39;<br>     AUTO_SUSPEND = 60<br>     AUTO_RESUME = TRUE;<br><br><br>&gt;&gt; sources/definitions/tables.sql<br><br>DEFINE TABLE {{ db_name }}.{{ schema_name }}.CUSTOMERS (<br>    ID INTEGER,<br>    NAME STRING,<br>    CREATED_AT TIMESTAMP<br>);<br><br><br>&gt;&gt; sources/definitions/views.sql<br><br>DEFINE VIEW {{ db_name }}.{{ schema_name }}.CUSTOMERS_VIEW<br>AS<br>SELECT ID, NAME FROM {{ db_name }}.{{ schema_name }}.CUSTOMERS;<br><br><br>&gt;&gt; sources/definitions/access.sql<br><br>DEFINE ROLE {{ role_name }}<br>COMMENT = &#39;Role for POC DCM {{ env }} environment&#39;;<br><br>GRANT USAGE ON DATABASE {{ db_name }} TO ROLE {{ role_name }};<br>GRANT USAGE ON SCHEMA {{ db_name }}.{{ schema_name }} TO ROLE {{ role_name }};<br>GRANT SELECT ON ALL TABLES IN SCHEMA {{ db_name }}.{{ schema_name }} TO ROLE {{ role_name }};<br>GRANT USAGE ON WAREHOUSE {{ warehouse_name }} TO ROLE {{ role_name }};</pre><h3>🧩 3. Prerequisites</h3><pre>- Snowflake CLI &gt;= 3.17 (check with: snow --version)<br>- A named connection in ~/.snowflake/connections.toml pointing to your account<br>- Create the project&#39;s parent schema (one-time, run manually in Snowflake):<br><br>    CREATE DATABASE IF NOT EXISTS DCM_ADMIN;<br>    CREATE SCHEMA IF NOT EXISTS DCM_ADMIN.PROJECTS;</pre><h3>🧩 4. Execution</h3><pre>All commands are run from the parent directory containing poc-dcm/.<br><br>Step 1: Create the DCM project (first time only)<br><br>    snow dcm create --from ./poc-dcm --target DEV -c default<br><br>Step 2: Analyze (validates syntax and dependencies, no changes applied)<br><br>    snow dcm raw-analyze --from ./poc-dcm --target DEV -c default --save-output<br><br>Step 3: Plan (previews what will be created/altered/dropped)<br><br>    snow dcm plan --from ./poc-dcm --target DEV -c default --save-output<br><br>Step 4: Deploy (applies changes to Snowflake)<br><br>    snow dcm deploy --from ./poc-dcm --target DEV -c default</pre><h3>🚀 5. Deploy to prod</h3><pre>No file changes required. Switch the target:<br><br>    snow dcm create --from ./poc-dcm --target PROD -c default --if-not-exists<br>    snow dcm plan --from ./poc-dcm --target PROD -c default --save-output<br>    snow dcm deploy --from ./poc-dcm --target PROD -c default</pre><h3>🔄 6. Version Control (GitOps)</h3><pre>Initialize the repository:<br><br>    cd poc-dcm<br>    git init<br>    git add manifest.yml sources/<br>    git commit -m &quot;Initial DCM project: database, table, view, warehouse, role&quot;<br><br>Workflow for changes:<br><br>    git checkout -b feature/add-orders-table<br>    # Edit sources/definitions/tables.sql to add ORDERS table<br>    git add sources/definitions/tables.sql<br>    git commit -m &quot;Add ORDERS table definition&quot;<br><br>    # Validate before merging<br>    snow dcm raw-analyze --from . --target DEV -c default<br>    snow dcm plan --from . --target DEV -c default --save-output<br><br>    # After code review and merge to main<br>    git checkout main<br>    git merge feature/add-orders-table<br>    snow dcm deploy --from . --target DEV -c default<br><br>Every definition change is committed, reviewed, and deployed through this cycle.<br>The git history becomes the audit trail for all infrastructure changes.</pre><h3>🧹 7. Cleanup</h3><pre>To remove all managed objects and the project after testing:<br><br>    snow dcm purge --from ./poc-dcm --target DEV -c default<br>    snow dcm drop DCM_ADMIN.PROJECTS.POC_DCM_PROJECT_DEV -c default</pre><p>Enjoy with DCM!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kvWyDdRwaTumtRioHcmJTg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ba7f8b017f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Complete Snowflake Cortex Intelligence POC — A Hands‑On Guide]]></title>
            <link>https://medium.com/@pmchancrin/building-a-complete-snowflake-cortex-intelligence-poc-a-hands-on-guide-24e9438a5ec6?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/24e9438a5ec6</guid>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Wed, 03 Jun 2026 23:37:54 GMT</pubDate>
            <atom:updated>2026-06-03T23:37:54.176Z</atom:updated>
            <content:encoded><![CDATA[<p>Snowflake has rapidly evolved from a cloud data warehouse into a full data‑intelligence platform. With the introduction of <strong>Snowflake Cortex</strong>, teams can now build AI‑powered applications directly where their data lives — without managing infrastructure or deploying external models.</p><p>In this tutorial, you’ll build a <strong>Proof of Concept (POC)</strong> that demonstrates how to use Snowflake Cortex to:</p><ul><li>Ingest and prepare data</li><li>Use built‑in LLM functions (e.g., SNOWFLAKE.CORTEX.COMPLETE)</li><li>Build embeddings and semantic search</li><li>Create an intelligent chatbot over your enterprise data</li><li>Expose everything through a simple Streamlit app inside Snowflake</li></ul><p>This guide is designed for hands‑on practitioners who want a realistic, end‑to‑end example they can adapt for real projects.</p><h3>1. Prerequisites</h3><p>Before starting, make sure you have:</p><ul><li>A Snowflake account (any edition supporting Snowflake Cortex)</li><li>A role with privileges to create databases, schemas, stages, and warehouses</li><li>A warehouse (e.g., COMPUTE_WH)</li><li>Basic familiarity with SQL and Snowflake concepts</li></ul><h3>2. Create the POC Environment</h3><p>sql</p><pre>USE ROLE ACCOUNTADMIN;<br>CREATE DATABASE CORTEX_POC;<br>CREATE SCHEMA CORTEX_POC.PUBLIC;<br>USE DATABASE CORTEX_POC;<br>USE SCHEMA PUBLIC;</pre><p>Create a warehouse if needed:</p><p>sql</p><pre>CREATE WAREHOUSE IF NOT EXISTS CORTEX_WH<br>  WAREHOUSE_SIZE = &#39;XSMALL&#39;<br>  AUTO_SUSPEND = 60<br>  AUTO_RESUME = TRUE;</pre><h3>3. Load Sample Data</h3><p>For this POC, we’ll use a simple dataset: product documentation or knowledge‑base articles.</p><h3>Create a table</h3><p>sql</p><pre>CREATE TABLE KB_ARTICLES (<br>  ID INTEGER,<br>  TITLE STRING,<br>  CONTENT STRING<br>);</pre><h3>Insert sample data</h3><p>sql</p><pre>INSERT INTO KB_ARTICLES VALUES<br>  (1, &#39;Resetting Your Password&#39;, &#39;To reset your password, go to settings...&#39;),<br>  (2, &#39;Troubleshooting Login Issues&#39;, &#39;If you cannot log in, first check...&#39;),<br>  (3, &#39;Managing Notifications&#39;, &#39;To manage notifications, open the preferences panel...&#39;);</pre><p>In a real POC, you would load PDFs, DOCX, or HTML files into a stage and extract text using Snowflake Document AI.</p><h3>4. Using Snowflake Cortex for Text Completion</h3><p>Snowflake Cortex exposes LLMs through SQL functions.</p><h3>Example: Summarize an article</h3><p>sql</p><pre>SELECT<br>  ID,<br>  SNOWFLAKE.CORTEX.COMPLETE(<br>    &#39;mixtral-8x7b&#39;,<br>    CONCAT(&#39;Summarize this article: &#39;, CONTENT)<br>  ) AS SUMMARY<br>FROM KB_ARTICLES;</pre><h3>Example: Generate a title suggestion</h3><p>sql</p><pre>SELECT<br>  SNOWFLAKE.CORTEX.COMPLETE(<br>    &#39;mixtral-8x7b&#39;,<br>    &#39;Generate a catchy title for an article about resetting passwords&#39;<br>  ) AS TITLE</pre><p>This already demonstrates value: AI‑powered enrichment directly in SQL.</p><h3>5. Build Embeddings for Semantic Search</h3><p>To enable intelligent Q&amp;A, we need embeddings.</p><h3>Create an embeddings table</h3><p>sql</p><pre>CREATE TABLE KB_EMBEDDINGS AS<br>SELECT<br>  ID,<br>  TITLE,<br>  CONTENT,<br>  SNOWFLAKE.CORTEX.EMBED_TEXT(&#39;e5-base&#39;, CONTENT) AS VECTOR<br>FROM KB_ARTICLES;</pre><h3>Query with semantic similarity</h3><p>sql</p><pre>WITH QUERY AS (<br>  SELECT SNOWFLAKE.CORTEX.EMBED_TEXT(&#39;e5-base&#39;, &#39;How do I change my password?&#39;) AS QV<br>)<br>SELECT<br>  ID,<br>  TITLE,<br>  VECTOR_COSINE_DISTANCE(VECTOR, QV) AS SCORE<br>FROM KB_EMBEDDINGS, QUERY<br>ORDER BY SCORE ASC<br>LIMIT 3;</pre><p>This retrieves the most relevant articles even if the wording differs.</p><h3>6. Build a Retrieval‑Augmented Generation (RAG) Function</h3><p>Now we combine semantic search + LLM completion.</p><h3>Create a stored procedure</h3><p>sql</p><pre>CREATE OR REPLACE PROCEDURE RAG_ANSWER(QUESTION STRING)<br>RETURNS STRING<br>LANGUAGE SQL<br>AS<br>$$<br>WITH QUERY AS (<br>  SELECT SNOWFLAKE.CORTEX.EMBED_TEXT(&#39;e5-base&#39;, QUESTION) AS QV<br>),<br>CONTEXT AS (<br>  SELECT CONTENT<br>  FROM KB_EMBEDDINGS, QUERY<br>  ORDER BY VECTOR_COSINE_DISTANCE(VECTOR, QV)<br>  LIMIT 3<br>),<br>PROMPT AS (<br>  SELECT CONCAT(<br>    &#39;You are an assistant. Use the following context to answer the question.\n\n&#39;,<br>    LISTAGG(CONTENT, &#39;\n\n&#39;),<br>    &#39;\n\nQuestion: &#39;, QUESTION, &#39;\nAnswer:&#39;<br>  ) AS P<br>  FROM CONTEXT<br>)<br>SELECT SNOWFLAKE.CORTEX.COMPLETE(&#39;mixtral-8x7b&#39;, P) AS ANSWER<br>FROM PROMPT;<br>$$;</pre><h3>Test it</h3><p>sql</p><pre>CALL RAG_ANSWER(&#39;How do I reset my password?&#39;);</pre><p>You now have a working enterprise chatbot backend.</p><h3>7. Build a Streamlit App Inside Snowflake</h3><p>Snowflake lets you deploy a UI directly in Snowsight.</p><h3>Create the app</h3><p>sql</p><pre>CREATE STREAMLIT CORTEX_CHAT<br>  FROM &#39;/streamlit&#39;<br>  MAIN_FILE = &#39;app.py&#39;;</pre><h3>Example app.py</h3><p>python</p><pre>import streamlit as st<br>import snowflake.snowpark as snowpark<br>def main():<br>    st.title(&quot;Snowflake Cortex Knowledge Assistant&quot;)<br><br>question = st.text_input(&quot;Ask a question about the knowledge base&quot;)<br>    if question:<br>        session = snowpark.Session.builder.getOrCreate()<br>        answer = session.sql(f&quot;CALL RAG_ANSWER(&#39;{question}&#39;)&quot;).collect()[0][0]<br>        st.write(&quot;### Answer&quot;)<br>        st.write(answer)<br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>Launch it from Snowsight → Streamlit → CORTEX_CHAT.</p><p>You now have a fully functional AI assistant powered entirely by Snowflake.</p><h3>8. Extending the POC</h3><p>Once the basics work, you can expand the POC with:</p><h3>Document AI</h3><ul><li>Extract text from PDFs</li><li>Auto‑classify documents</li><li>Detect entities</li></ul><h3>Cortex Search</h3><ul><li>Build a full semantic search index</li><li>Query with natural language</li></ul><h3>Cortex Fine‑Tuning</h3><ul><li>Train models on your own data</li><li>Improve accuracy for domain‑specific tasks</li></ul><h3>Snowpark Container Services</h3><ul><li>Deploy custom models</li><li>Run Python agents</li><li>Integrate vector databases</li></ul><h3>9. Conclusion</h3><p>This POC demonstrates how Snowflake Cortex can transform raw enterprise data into an intelligent application — without leaving the Snowflake ecosystem. You’ve built:</p><ul><li>A knowledge‑base dataset</li><li>LLM‑powered enrichment</li><li>Embeddings and semantic search</li><li>A RAG pipeline</li><li>A Streamlit chatbot</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6E1XcZoo4vhl3H6B-wVJXQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24e9438a5ec6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cortex Cli in Action !]]></title>
            <link>https://medium.com/@pmchancrin/cortex-cli-in-action-004e56d5631b?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/004e56d5631b</guid>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Wed, 03 Jun 2026 23:29:10 GMT</pubDate>
            <atom:updated>2026-06-03T23:29:10.495Z</atom:updated>
            <content:encoded><![CDATA[<p>Snowflake Cortex CLI brings secure, contextual AI assistance directly into key data engineering tools like dbt and Apache Airflow, significantly reducing friction and accelerating development.</p><p>It helps teams work with data wherever it resides, build and optimize production-grade workflows faster, and avoid context switching — a major productivity bottleneck.</p><p><strong>Prerequisite</strong></p><p>On Snowflake Account activate Cortex Code like below</p><p>— 1. Enable cross-region access to models (already done via Python)<br>ALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = ‘ANY_REGION’;</p><p>- 2. Allow all LLM models (already done via Python)<br>ALTER ACCOUNT SET CORTEX_MODELS_ALLOWLIST = ‘All’;</p><p>- 3. Grant Cortex privileges to the ACCOUNTADMIN role<br>GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE ACCOUNTADMIN;</p><ul><li>4. Verify that the parameters are correctly applied<br>SHOW PARAMETERS LIKE ‘CORTEX%’ IN ACCOUNT;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5DDD4_S8wtPV7vQp-n5Pg.png" /></figure><p>Here’s how to implement it in VS Code</p><p><strong>1. Install Snowflake CLI in a virtual environment</strong></p><p>```bash</p><p>python3 -m venv ~/snowflake-cli-env</p><p>~/snowflake-cli-env/bin/pip install snowflake-cli</p><p>```</p><p><strong>2. Create the configuration file</strong></p><p>```bash</p><p>mkdir -p ~/.snowflake</p><p>nano ~/.snowflake/config.toml</p><p>```</p><p>Paste the following content (adjust values as needed):</p><p>```toml</p><p>default_connection_name = “cortex”</p><p>[cli]</p><p>ignore_new_version_warning = false</p><p>[cli.logs]</p><p>save_logs = true</p><p>path = “/home/&lt;your_user&gt;/.snowflake/logs”</p><p>level = “info”</p><p>[connections.cortex]</p><p>account = “LKTZEIC-UL65726”</p><p>user = “Piermick”</p><p>password = “Azerty12341234”</p><p>role = “accountadmin”</p><p>warehouse = “compute_wh”</p><p>database = “admin”</p><p>schema = “sh_piermick”</p><p>```</p><p>to avoid storing the password in plain text, remove the `password` line and set an environment variable instead:</p><p>&gt; ```bash</p><p>&gt; export SNOWFLAKE_PASSWORD=”Azerty10021002&quot;</p><p>&gt; ```</p><p>&gt; Add it to `~/.bashrc` to make it permanent.</p><p>Apply mandatory permissions on Linux:</p><p>```bash</p><p>chmod 0600 ~/.snowflake/config.toml</p><p>```</p><p><strong>3. Configure aliases and helpers in `.bashrc`</strong></p><p>```bash</p><p>cat &gt;&gt; ~/.bashrc &lt;&lt; ‘EOF’</p><p># Snowflake Cortex helper</p><p>alias snow=~/snowflake-cli-env/bin/snow</p><p>cortex() {</p><p>local prompt=”${*}”</p><p>echo “SELECT SNOWFLAKE.CORTEX.COMPLETE(‘snowflake-arctic’, \$\$${prompt}\$\$);” \</p><p>| ~/snowflake-cli-env/bin/snow sql — stdin -c cortex</p><p>}</p><p>EOF</p><p>source ~/.bashrc</p><p>```</p><p><strong>4. Test the connection</strong></p><p>```bash</p><p>snow connection test -c cortex</p><p>```</p><p>Expected output:</p><p>```</p><p>+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — — +</p><p>| key | value |</p><p>| — — — — — — — — -+ — — — — — — — — — — — — — — — — — — — — |</p><p>| Connection name | cortex |</p><p>| Status | OK |</p><p>| Host | LKTZEIC-UL65726.snowflakecomputing.com |</p><p>| Account | LKTZEIC-UL65726 |</p><p>| User | PIERMICK |</p><p>| Role | ACCOUNTADMIN |</p><p>| Database | ADMIN |</p><p>| Warehouse | COMPUTE_WH |</p><p>+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — — +</p><p>```</p><p>Enjoy with Cortex Cli !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*af1uOtZyENFJ1ZCsF18FXA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=004e56d5631b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A la découverte de dbt Canvas]]></title>
            <link>https://medium.com/@pmchancrin/a-la-d%C3%A9couverte-de-dbt-canvas-4bb8d5287495?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bb8d5287495</guid>
            <category><![CDATA[snowflake-computing]]></category>
            <category><![CDATA[dbt-labs]]></category>
            <category><![CDATA[dbt-cloud]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[snowflake-data-cloud]]></category>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Tue, 26 May 2026 11:34:13 GMT</pubDate>
            <atom:updated>2026-05-26T11:34:13.470Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧐 Qu’est-ce que dbt Canvas ?</h3><p>dbt Canvas est une nouveauté dans l’écosystème dbt (data build tool), proposée par <a href="https://www.linkedin.com/company/dbtlabs/">dbt Labs</a> dans les plans Enterprise / Enterprise+.</p><p>L’idée : fournir une interface visuelle, de type “drag-and-drop”, permettant de construire des modèles dbt sans forcément écrire SQL directement, ou en tout cas en combinant éléments visuels + génération de code automatique. Cette fonctinnalité est très pratique pour tester ces transformations sur <a href="https://www.linkedin.com/company/snowflake-computing/">Snowflake</a> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WTEiaiv3brYIfMP0" /></figure><p>Quelques points clés :</p><ul><li>Tu peux créer ou éditer des modèles dbt dans Canvas via des opérateurs (“operators”) : Input, Transform, Output.</li><li>Il y a un aperçu (“preview”) des données à chaque étape — ce qui permet de tester les transformations dans Canvas sans impacter immédiatement la base de données de production.</li><li>Le SQL est généré automatiquement, compilé comme si tu avais écrit le modèle “classique” — les modèles Canvas deviennent des fichiers dbt comme les autres.</li><li>Intégration avec Git : tes modèles visuels sont versionnés via Git, et les changements peuvent être commités, pull requestés,etc.</li><li>Possibilité d’utiliser des fonctionnalités IA (“Copilot”) pour générer du code ou aider à construire le modèle via langage naturel.</li></ul><h3>✅ Avantages de Canvas</h3><p>Voici ce que Canvas permet (et ce qu’il apporte) :</p><ol><li>Abaisser la barrière d’entrée Pour des analystes ou des utilisateurs moins à l’aise avec le SQL pur, cela peut rendre la modélisation de données plus accessible. On peut “voir” les transformations plutôt que de ne les définir que par du code.</li><li>Iterer plus rapidement Avec les aperçus (previews), on peut tester des transformations, des jointures, des agrégations, etc., sans attendre une exécution complète ou risquer de casser quelque chose en production.</li><li>Standardisation / collaboration Tout reste dans l’écosystème dbt : Canvas génère du SQL qui s’intègre dans les projets existants, versionné via Git, utilisable dans les environnements de staging / production comme les autres modèles. Cela permet de garder rigueur, relecture, tests, etc.</li><li>Visualisation La structure des transformations (flux, dépendances, opérateurs) est plus claire visuellement, ce qui aide à la compréhension, la revue ou la documentation.</li></ol><h3>⚠️ Limites / Prérequis / Ce qu’il faut surveiller</h3><p>Mais ce n’est pas parfait, voici ce qu’il faut savoir :</p><ul><li>Plan payant requis : il faut un compte dbt Enterprise ou Enterprise+ pour avoir accès à Canvas.</li><li>Adaptateurs supportés : seulement certains adaptateurs (“adapters”) comme BigQuery, Snowflake, Redshift, Databricks, Trino sont pleinement supportés. Avec d’autres, certaines fonctionnalités peuvent manquer.</li><li>Configuration initiale nécessaire : projet dbt déjà existant, exécution (“run”) dans staging ou production, Git configuré, droits d’accès adéquats, etc.</li><li>Attention au SQL généré : même si Canvas aide avec visuel + IA, il est toujours recommandé de vérifier le SQL généré, pour s’assurer qu’il est optimal, respecte les conventions, gère bien les cas limites.</li><li>Complexité des transformations : pour des transformations très complexes ou des optimisations poussées, l’approche visuelle peut devenir limitante — parfois il sera nécessaire de retoucher manuellement le SQL ou de sortir du Canvas.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bb8d5287495" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering AI Cost and Access: The Imperative of Governance for Snowflake Cortex Code]]></title>
            <link>https://medium.com/snowflake/mastering-ai-cost-and-access-the-imperative-of-governance-for-snowflake-cortex-code-b0ceecd6a746?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0ceecd6a746</guid>
            <category><![CDATA[ai-governance]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Mon, 11 May 2026 17:18:47 GMT</pubDate>
            <atom:updated>2026-05-11T17:18:47.991Z</atom:updated>
            <content:encoded><![CDATA[<p>The integration of Generative AI directly into the data cloud via Snowflake Cortex Code represents a massive leap in developer productivity. By bringing Large Language Models (LLMs) like OpenAI’s GPT and Anthropic’s Claude directly to where the data lives, teams can generate SQL, debug pipelines, and analyze datasets faster than ever.</p><p>However, this democratization of AI comes with a significant caveat: <strong>compute costs</strong>. LLMs charge by the token, and unrestricted access to premium models can quickly lead to budget overruns. Implementing a robust governance and quota framework is no longer optional; it is a critical requirement for any enterprise utilizing Snowflake Cortex.</p><p>Here is a breakdown of why governing Cortex Code is essential, how the provided script practically enforces these guardrails, and concrete examples of how to apply it across your organization.</p><h3>Why Governance and Quotas Matter for Cortex Code</h3><p>Deploying AI without governance is like handing over a corporate credit card without a spending limit. Implementing a structured access and quota system solves several critical business challenges:</p><ul><li><strong>Cost Predictability and Control:</strong> Premium models (like Claude Opus) are significantly more expensive than standard models. Quotas prevent runaway costs caused by inefficient prompts, automated scripts gone rogue, or excessive daily usage.</li><li><strong>Principle of Least Privilege (PoLP):</strong> Not every user needs access to the most powerful, expensive AI models. Governance ensures users only have access to the tools necessary for their specific job functions.</li><li><strong>Auditability and Security:</strong> By disabling global access and explicitly granting roles, security teams can easily audit exactly who is using which AI model and when.</li><li><strong>Resource Allocation:</strong> It ensures that your AI budget is spent where it generates the most ROI — reserving heavy-duty processing for complex architectural problems rather than basic SQL syntax checks.</li></ul><h3>Deconstructing the Governance Script</h3><p>The provided SQL script is an excellent, production-ready blueprint for establishing Cortex Code governance. It utilizes Role-Based Access Control (RBAC) and dynamic quota assignments to create a tiered system. Here is why the script is highly effective:</p><h3>1. The “Default Deny” Stance</h3><p>The most important security command in the script is ALTER ACCOUNT SET CORTEX_MODELS_ALLOWLIST = &#39;None&#39;;. By default, Snowflake might allow broad access to models. This command shuts the front door, forcing all model access to go through the explicitly defined RBAC roles.</p><h3>2. Tiered Role Architecture</h3><p>The script logically divides the workforce into three distinct tiers, utilizing role inheritance so higher tiers automatically gain the permissions of lower tiers:</p><ul><li><strong>Standard (</strong><strong>CORTEX_CODE_STANDARD):</strong> Access to highly capable but cost-efficient models (e.g., GPT-4o-mini equivalents, base Sonnet).</li><li><strong>Enhanced (</strong><strong>CORTEX_CODE_ENHANCED):</strong> Adds access to more capable reasoning models.</li><li><strong>Premium (</strong><strong>CORTEX_CODE_PREMIUM):</strong> Grants access to the most powerful, expensive models available (e.g., Claude 3 Opus).</li></ul><h3>3. Dynamic Quota Enforcement</h3><p>Snowflake allows setting credit limits at the account level, but this script takes a much smarter approach. It uses Snowflake Scripting (dynamic SQL loops) to identify exactly which users hold which roles, and explicitly applies a daily credit limit (CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER) tailored to their tier. It even separates CLI constraints from UI (Snowsight) constraints.</p><h3>Concrete Use Cases: Who Gets What?</h3><p>To understand the utility of this script, let’s look at how these roles map to real-world teams and daily tasks.</p><h3>Tier 1: Standard (2 Credits/Day)</h3><ul><li><strong>Target Audience:</strong> Junior Developers, Data Analysts, Business Intelligence (BI) users.</li><li><strong>Assigned Models:</strong> Cost-efficient baseline models.</li><li><strong>Concrete Use Case:</strong> A Data Analyst needs to write a complex JOIN or aggregate data using window functions. They use Cortex in Snowsight to ask, <em>&quot;Write a SQL query to find the rolling 7-day average of sales per region.&quot;</em> The standard models handle this perfectly with minimal credit consumption. The 2-credit limit acts as a guardrail against treating the AI as a conversational chatbot.</li></ul><h3>Tier 2: Enhanced (5 Credits/Day)</h3><ul><li><strong>Target Audience:</strong> Senior Data Engineers, Tech Leads, Analytics Engineers.</li><li><strong>Assigned Models:</strong> Advanced reasoning models (e.g., Claude 3.5 Sonnet).</li><li><strong>Concrete Use Case:</strong> A Data Engineer is debugging a failing stored procedure written in Snowflake Scripting or Python (Snowpark) that processes millions of rows. They paste the code block into the Cortex CLI and ask, <em>“Identify the memory leak or logic flaw in this Snowpark Python dataframe transformation.”</em> This requires deeper logical reasoning and context windows, justifying the higher-tier models and the 5-credit daily limit.</li></ul><h3>Tier 3: Premium (Unlimited / High Limit)</h3><ul><li><strong>Target Audience:</strong> Data Architects, Principal Engineers, Security Analysts.</li><li><strong>Assigned Models:</strong> Top-tier foundational models (e.g., Claude 3 Opus).</li><li><strong>Concrete Use Case:</strong> A Data Architect is designing a new multi-tenant data mesh architecture. They need the AI to analyze extensive documentation, generate a comprehensive schema design, and draft the initial infrastructure-as-code boilerplate. This is a highly complex, token-intensive task where the quality of the output dictates the success of a major project. Because these users are trusted and the ROI is high, they are granted access to Opus without a restrictive daily cap.</li></ul><p>Here is the code:</p><pre>-- ====================================================================<br>-- INPUT VARIABLES — edit these values before executing<br>-- ====================================================================<br>SET ADMIN_ROLE          = &#39;CORTEX_ACCESS_ADMIN&#39;;<br>SET ROLE_STANDARD       = &#39;CORTEX_CODE_STANDARD&#39;;<br>SET ROLE_ENHANCED       = &#39;CORTEX_CODE_ENHANCED&#39;;<br>SET ROLE_PREMIUM        = &#39;CORTEX_CODE_PREMIUM&#39;;<br>SET CREDITS_STANDARD    = 2;      -- daily credit limit for STANDARD users<br>SET CREDITS_ENHANCED    = 5;      -- daily credit limit for ENHANCED users<br>SET CREDITS_UNLIMITED   = -1;     -- -1 = no limit (PREMIUM + ACCOUNTADMIN)<br>SET MODEL_STANDARD_1    = &#39;CORTEX-MODEL-ROLE-OPENAI-GPT-5.2&#39;;<br>SET MODEL_STANDARD_2    = &#39;CORTEX-MODEL-ROLE-CLAUDE-4-SONNET&#39;;<br>SET MODEL_ENHANCED_1    = &#39;CORTEX-MODEL-ROLE-CLAUDE-SONNET-4-5&#39;;<br>SET MODEL_ENHANCED_2    = &#39;CORTEX-MODEL-ROLE-CLAUDE-SONNET-4-6&#39;;<br>SET MODEL_PREMIUM_1     = &#39;CORTEX-MODEL-ROLE-CLAUDE-4-OPUS&#39;;<br><br>-- ====================================================================<br>-- 1. BASE CONFIGURATION &amp; SECURITY<br>-- ====================================================================<br><br>-- Create a dedicated admin role for the Platform team<br>CREATE ROLE IF NOT EXISTS IDENTIFIER($ADMIN_ROLE);<br>ALTER ROLE IDENTIFIER($ADMIN_ROLE) COMMENT = &#39;Manages access to Cortex Code tiers.&#39;;<br>GRANT ROLE IDENTIFIER($ADMIN_ROLE) TO ROLE SYSADMIN;<br><br>-- Disable global model access to enforce RBAC exclusively<br>ALTER ACCOUNT SET CORTEX_MODELS_ALLOWLIST = &#39;None&#39;;<br><br>-- Refresh the model registry to ensure Application Roles exist<br>CALL SNOWFLAKE.MODELS.CORTEX_BASE_MODELS_REFRESH();<br><br>-- ====================================================================<br>-- 2. TIER ROLE CREATION<br>-- ====================================================================<br><br>CREATE ROLE IF NOT EXISTS IDENTIFIER($ROLE_STANDARD);<br>CREATE ROLE IF NOT EXISTS IDENTIFIER($ROLE_ENHANCED);<br>CREATE ROLE IF NOT EXISTS IDENTIFIER($ROLE_PREMIUM);<br><br>ALTER ROLE IDENTIFIER($ROLE_STANDARD) COMMENT = &#39;Default tier (GPT + base Sonnet). For all engineers.&#39;;<br>ALTER ROLE IDENTIFIER($ROLE_ENHANCED) COMMENT = &#39;Adds recent Sonnet variants. For seniors / tech leads.&#39;;<br>ALTER ROLE IDENTIFIER($ROLE_PREMIUM)  COMMENT = &#39;Adds Opus. Architecture / Security. Manager approval required.&#39;;<br><br>-- ====================================================================<br>-- 3. INTERFACE ACCESS (CLI AND SNOWSIGHT)<br>-- ====================================================================<br><br>-- CORTEX_USER enables agent capabilities. COPILOT_USER enables the icon in Snowsight.<br>-- (To restrict to CLI only for certain users, do not grant COPILOT_USER)<br>GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER  TO ROLE IDENTIFIER($ROLE_STANDARD);<br>GRANT DATABASE ROLE SNOWFLAKE.COPILOT_USER TO ROLE IDENTIFIER($ROLE_STANDARD);<br><br>-- Inheritance: higher tier inherits everything from the lower tier<br>GRANT ROLE IDENTIFIER($ROLE_STANDARD) TO ROLE IDENTIFIER($ROLE_ENHANCED);<br>GRANT ROLE IDENTIFIER($ROLE_ENHANCED) TO ROLE IDENTIFIER($ROLE_PREMIUM);<br><br>-- ====================================================================<br>-- 4. MODEL ASSIGNMENT TO ROLES (RBAC)<br>-- ====================================================================<br>-- Note: exact names may change — verify with: SHOW APPLICATION ROLES IN APPLICATION SNOWFLAKE;<br><br>-- STANDARD: most cost-efficient models<br>EXECUTE IMMEDIATE &#39;GRANT APPLICATION ROLE SNOWFLAKE.&quot;&#39; || $MODEL_STANDARD_1 || &#39;&quot; TO ROLE &#39; || $ROLE_STANDARD;<br>EXECUTE IMMEDIATE &#39;GRANT APPLICATION ROLE SNOWFLAKE.&quot;&#39; || $MODEL_STANDARD_2 || &#39;&quot; TO ROLE &#39; || $ROLE_STANDARD;<br><br>-- ENHANCED: advanced Sonnet models<br>EXECUTE IMMEDIATE &#39;GRANT APPLICATION ROLE SNOWFLAKE.&quot;&#39; || $MODEL_ENHANCED_1 || &#39;&quot; TO ROLE &#39; || $ROLE_ENHANCED;<br>EXECUTE IMMEDIATE &#39;GRANT APPLICATION ROLE SNOWFLAKE.&quot;&#39; || $MODEL_ENHANCED_2 || &#39;&quot; TO ROLE &#39; || $ROLE_ENHANCED;<br><br>-- PREMIUM: most powerful and expensive model (Opus)<br>EXECUTE IMMEDIATE &#39;GRANT APPLICATION ROLE SNOWFLAKE.&quot;&#39; || $MODEL_PREMIUM_1 || &#39;&quot; TO ROLE &#39; || $ROLE_PREMIUM;<br><br>-- ====================================================================<br>-- 5. USER ASSIGNMENT AND CREDIT LIMITS<br>-- ====================================================================<br><br>-- Account-level default (applies to all users)<br>ALTER ACCOUNT SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER      = $CREDITS_STANDARD;<br>ALTER ACCOUNT SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = $CREDITS_STANDARD;<br><br>-- Override for STANDARD users: 2 credits/day<br>EXECUTE IMMEDIATE $$<br>DECLARE<br>    v_credits     INT     DEFAULT $CREDITS_STANDARD;<br>    v_role        STRING  DEFAULT &#39;$ROLE_STANDARD&#39;;<br>    rs            RESULTSET;<br>    user_name     STRING;<br>BEGIN<br>    EXECUTE IMMEDIATE &#39;SHOW GRANTS OF ROLE &#39; || :v_role;<br>    rs := (SELECT &quot;grantee_name&quot; FROM TABLE(RESULT_SCAN(LAST_QUERY_ID())) WHERE &quot;granted_to&quot; = &#39;USER&#39;);<br>    FOR rec IN rs DO<br>        user_name := rec.&quot;grantee_name&quot;;<br>        EXECUTE IMMEDIATE &#39;ALTER USER &quot;&#39; || :user_name || &#39;&quot; SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = &#39; || v_credits;<br>        EXECUTE IMMEDIATE &#39;ALTER USER &quot;&#39; || :user_name || &#39;&quot; SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = &#39; || v_credits;<br>    END FOR;<br>    RETURN &#39;STANDARD override applied (&#39; || v_credits || &#39; credits/day)&#39;;<br>END;<br>$$;<br><br>-- Override for ENHANCED users: 5 credits/day<br>EXECUTE IMMEDIATE $$<br>DECLARE<br>    v_credits     INT     DEFAULT $CREDITS_ENHANCED;<br>    v_role        STRING  DEFAULT &#39;$ROLE_ENHANCED&#39;;<br>    rs            RESULTSET;<br>    user_name     STRING;<br>BEGIN<br>    EXECUTE IMMEDIATE &#39;SHOW GRANTS OF ROLE &#39; || :v_role;<br>    rs := (SELECT &quot;grantee_name&quot; FROM TABLE(RESULT_SCAN(LAST_QUERY_ID())) WHERE &quot;granted_to&quot; = &#39;USER&#39;);<br>    FOR rec IN rs DO<br>        user_name := rec.&quot;grantee_name&quot;;<br>        EXECUTE IMMEDIATE &#39;ALTER USER &quot;&#39; || :user_name || &#39;&quot; SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = &#39; || v_credits;<br>        EXECUTE IMMEDIATE &#39;ALTER USER &quot;&#39; || :user_name || &#39;&quot; SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = &#39; || v_credits;<br>    END FOR;<br>    RETURN &#39;ENHANCED override applied (&#39; || v_credits || &#39; credits/day)&#39;;<br>END;<br>$$;<br><br>-- Override for PREMIUM users: unlimited<br>EXECUTE IMMEDIATE $$<br>DECLARE<br>    v_credits     INT     DEFAULT $CREDITS_UNLIMITED;<br>    v_role        STRING  DEFAULT &#39;$ROLE_PREMIUM&#39;;<br>    rs            RESULTSET;<br>    user_name     STRING;<br>BEGIN<br>    EXECUTE IMMEDIATE &#39;SHOW GRANTS OF ROLE &#39; || :v_role;<br>    rs := (SELECT &quot;grantee_name&quot; FROM TABLE(RESULT_SCAN(LAST_QUERY_ID())) WHERE &quot;granted_to&quot; = &#39;USER&#39;);<br>    FOR rec IN rs DO<br>        user_name := rec.&quot;grantee_name&quot;;<br>        EXECUTE IMMEDIATE &#39;ALTER USER &quot;&#39; || :user_name || &#39;&quot; SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = &#39; || v_credits;<br>        EXECUTE IMMEDIATE &#39;ALTER USER &quot;&#39; || :user_name || &#39;&quot; SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = &#39; || v_credits;<br>    END FOR;<br>    RETURN &#39;PREMIUM override applied (unlimited)&#39;;<br>END;<br>$$;<br><br>-- Override for ACCOUNTADMIN users: unlimited<br>EXECUTE IMMEDIATE $$<br>DECLARE<br>    v_credits     INT     DEFAULT $CREDITS_UNLIMITED;<br>    rs            RESULTSET;<br>    user_name     STRING;<br>BEGIN<br>    EXECUTE IMMEDIATE &#39;SHOW GRANTS OF ROLE ACCOUNTADMIN&#39;;<br>    rs := (SELECT &quot;grantee_name&quot; FROM TABLE(RESULT_SCAN(LAST_QUERY_ID())) WHERE &quot;granted_to&quot; = &#39;USER&#39;);<br>    FOR rec IN rs DO<br>        user_name := rec.&quot;grantee_name&quot;;<br>        EXECUTE IMMEDIATE &#39;ALTER USER &quot;&#39; || :user_name || &#39;&quot; SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = &#39; || v_credits;<br>        EXECUTE IMMEDIATE &#39;ALTER USER &quot;&#39; || :user_name || &#39;&quot; SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = &#39; || v_credits;<br>    END FOR;<br>    RETURN &#39;ACCOUNTADMIN override applied (unlimited)&#39;;<br>END;<br>$$;</pre><p>The result is like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bdjjJbhDDUSgZRh0NkMnOQ.png" /></figure><h3>Summary</h3><p>Implementing a script like the one provided transitions your organization from “experimenting with AI” to “scaling AI responsibly.” By binding specific models and hard credit limits to your existing Snowflake RBAC structure, you empower your engineering teams to innovate while giving your finance and security teams the peace of mind they require.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0ceecd6a746" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/mastering-ai-cost-and-access-the-imperative-of-governance-for-snowflake-cortex-code-b0ceecd6a746">Mastering AI Cost and Access: The Imperative of Governance for Snowflake Cortex Code</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</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 migrate from PostgreSQL to PostgreSQL on Snowflake?]]></title>
            <link>https://medium.com/snowflake/how-to-migrate-from-postgresql-to-postgresql-on-snowflake-08fa0555e7e1?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/08fa0555e7e1</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Wed, 22 Apr 2026 17:01:05 GMT</pubDate>
            <atom:updated>2026-04-22T17:01:05.129Z</atom:updated>
            <content:encoded><![CDATA[<h3>🏢 The context: When is this migration wise?</h3><p><strong>Context 1: The dream of ‘Zero ETL’ (Linking the application and analysis)</strong></p><ul><li>The Data team needs this data in Snowflake to create decision-making dashboards or to train machine learning models. Currently, they use tools like Fivetran, Airbyte, or complex custom scripts to copy data from Postgres to Snowflake every few hours. This method is costly, fragile, and the data is never truly up-to-date.</li><li>The Snowflake Postgres solution: by migrating the application’s database to Snowflake Postgres, transactional data is integrated into the Snowflake ecosystem. Data engineers can thus query this data directly, as well as the history, without having to create or manage ETL pipelines. Analysis is instant and real-time. ETL” (Linking the application to analysis)</li></ul><p><strong>Context 2: ‘Supplier consolidation’ (simplification of DevOps and FinOps)</strong></p><ul><li>Problem: A technical team is overwhelmed. It pays AWS for hosting its RDS Postgres database, another provider for database security, and Snowflake for its data warehouse. Its DevOps team spends excessive time on server maintenance and managing different cloud environments.</li><li>The Snowflake solution for Postgres: centralize everything. By migrating Postgres to Snowflake, you only have one provider, one bill, and a unified security and governance model. The DevOps team no longer has to manage the infrastructure, as it is fully handled by Snowflake.</li></ul><p><strong>Context 3: Creation of ‘data-intensive’ applications</strong></p><ul><li>The problem: a company wants to create a dashboard for users within its application, displaying complex and large-scale analytics (for example, a merchant viewing the year-over-year trend of their sales across millions of rows), but standard Postgres struggles to handle these massive analytical queries.</li><li>The Snowflake Postgres solution: the application continues to write transactions into the Postgres engine (which it handles perfectly), but it can seamlessly leverage Snowflake’s powerful analytical computation engine for heavy read queries, all within the same environment.</li></ul><h3>🛠️ How to migrate (The process)</h3><p>Snowflake Postgres being a true PostgreSQL engine, the migration is extremely simple. You do not need complex data mapping or Snowflake-specific extraction tools.</p><p>When creating the instance (via the user interface or the SQL script), Snowflake generates the initial access credentials. It is imperative to immediately copy this information into a notepad, as the password will only be displayed once.</p><ul><li><strong>Username </strong>(default: snowflake_admin)</li><li><strong>Password </strong>(randomly generated)</li><li><strong>Host name</strong> (The login URL, which looks like abc123xyz…postgres.snowflake.app)</li></ul><p>Once your poc_pg_migrationinstance is active, you will no longer need CSV files. You can directly use the native Postgres tools (like a simple pg_dump command on your source database and another pg_restore pointing to the Snowflake hostname) to perform your migration!</p><h3>Step 1: Preparation of the source and generation of ‘fake’ data</h3><p>On your source PostgreSQL instance (local or on an existing server), run this script to create your demonstration database and generate a volume of dummy data.</p><pre>-- 1. Creation of the source database<br>CREATE DATABASE boutique_source;<br>c boutique_source;<br><br>-- 2. Creation of tables<br>CREATE TABLE clients (<br>client_id SERIAL PRIMARY KEY,<br>first_name VARCHAR(50),<br>last_name VARCHAR(50),<br>email VARCHAR(100) UNIQUE,<br>registration_date DATE DEFAULT CURRENT_DATE<br>);<br>commandes CREATE TABLE ( <br>    commande_id SERIAL PRIMARY KEY, <br>    client_id INT REFERENCES clients(client_id), <br>    montant DECIMAL(10, 2), <br>    statut VARCHAR(20), <br>    date_commande TIMESTAMP DEFAULT CURRENT_TIMESTAMP <br>);<br>-- 3. Generation of 10,000 fake clients<br>INSERT INTO clients (first_name, last_name, email, registration_date)<br>SELECT<br>&#39;FirstName_&#39; || seq,<br>&#39;LastName_&#39; || seq,<br>&#39;user_&#39; || seq || &#39;@devoteam-poc.com&#39;,<br>CURRENT_DATE - (random() * 365)::integer<br>FROM generate_series(1, 10000) seq;<br>-- 4. Generation of 50,000 fictitious orders<br>INSERT INTO orders (client_id, amount, status, order_date)<br>SELECT<br>(random() * 9999 + 1)::integer,<br>(random() * 500 + 10)::numeric(10,2),<br>CASE<br>WHEN random() &gt; 0.3 THEN &#39;Delivered&#39;<br>WHEN random() &gt; 0.1 THEN &#39;In progress&#39;<br>ELSE &#39;Cancelled&#39;<br>END,<br>NOW() - (random() * 365 * 24 * 60 * 60) * interval &#39;1 second&#39;<br>FROM generate_series(1, 50000);</pre><h3>Step 2: Creating the Snowflake Postgres Instance (Target)</h3><p>We need to create a PostgreSQL database from the user interface, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-m99uHIfqJ173HgJhaRLJQ.png" /></figure><p>Or, via spreadsheets, instead of creating analytical tables, you will directly instantiate the Postgres engine in Snowflake. In a Snowflake spreadsheet (with the ACCOUNTADMIN role), execute:</p><pre>USE ROLE ACCOUNTADMIN;<br><br>-- Creation of the managed Postgres instance<br>CREATE POSTGRES INSTANCE poc_pg_boutique<br>COMPUTE_FAMILY = &#39;BURSTABLE_S&#39;<br>STORAGE_SIZE_GB = 10<br>POSTGRES_VERSION = 16<br>AUTHENTICATION_AUTHORITY = POSTGRES<br>COMMENT = &#39;Target instance for the POC migration&#39;;</pre><p>🚨 Crucial step: Immediately retrieve the access information generated by Snowflake (host name, snowflake_admin username, and the unique password).</p><h3>Step 3: Migration using standard Postgres tools</h3><p>This is where the magic happens for your demonstration. Open your terminal (command prompt) on the machine where your source database is located. We will use pg_dump to extract the data and pg_restore (or psql) to inject it, thus demonstrating native compatibility.</p><p><strong>1. </strong>Backup of the source database (Dump):</p><pre># Export the schema and data from the source database to a file<br> pg_dump -U ton_user_local -h localhost -d boutique_source -F c  -f  boutique_poc.dump</pre><p><strong>2. </strong>Restoration to Snowflake Postgres: Use the host name provided by Snowflake when creating the instance.</p><pre># Restore the backup directly into your Snowflake Postgres instance<br> : pg_restore -U snowflake_admin -h &lt;ton-hostname-snowflake&gt;.postgres.snowflake.app -d postgres -1 boutique_poc.dump</pre><p>(The password generated in step 2 will be requested from you).</p><h3>Step 4: Verification and Next Steps (To close the demonstration)</h3><p>To prove that the migration worked and that you are indeed using a real managed Postgres engine, connect to the Snowflake Postgres instance with any standard client (DBeaver, DataGrip, or psql):</p><pre>psql -U snowflake_admin -h &lt; votre-nom-d&#39;hôte-snowflake &gt; .postgres.snowflake.app -d postgres</pre><p>Then launch a few live verification requests:</p><pre>-- Volumetric check<br>SELECT  COUNT ( * ) FROM clients; <br>SELECT  COUNT ( * ) FROM commandes;<br><br>-- Typical transactional request<br>SELECT c.prenom, c.nom, SUM(cmd.montant) as total_depense <br>FROM clients c <br>JOIN commandes cmd ON c.client_id = cmd.client_id <br>GROUP BY c.client_id <br>ORDER BY total_depense DESC <br>LIMIT 5;</pre><h3>“Added value” or “return on investment” of this migration:</h3><h3>🚀 1. Zero operational overhead costs (complete management)</h3><ul><li>Simplified infrastructure maintenance: Snowflake handles patch management, high availability, and backups. No more need to provision servers, manage the operating system, or schedule updates.</li><li>Focus on value: your teams (database administrators, data engineers) stop managing the “infrastructure” and can focus entirely on optimizing data models and building applications.</li></ul><h3>🔗2. OLTP and OLAP Convergence (The end of silos and complex ETL processes)</h3><ul><li>This is the “flagship feature.” Traditionally, transactional databases (OLTP — Postgres) and analytical data warehouses (OLAP — Snowflake) are strictly separated, which requires costly and fragile integration pipelines (ETL/ELT) to synchronize the data.</li><li>Zero ETL: By hosting Postgres directly in Snowflake, your transactional data is immediately accessible from the analytics platform. This allows near real-time analysis of production data without impacting the performance of the source application.</li></ul><h3>🔄 3. Native compatibility with PostgreSQL (no refactoring)</h3><ul><li>No dependency on an application provider: Snowflake Postgres is a true Postgres engine. Your business applications, APIs, ORMs (Hibernate, Prisma, etc.), and standard query tools (DBeaver, pgAdmin) will continue to work exactly as before.</li><li>You literally just need to update the connection string (the host name) in the target application. The technical complexity is minimal.</li></ul><h3>🛡️ 4. Unified governance and security</h3><ul><li>A unique ecosystem: you centralize access management, security policies, sensitive data masking, and auditing within a single platform.</li><li>It is no longer necessary to maintain separate and redundant security rules on your cloud provider (for example, AWS RDS) and on Snowflake.</li></ul><h3>💰5. Billing Consolidation (FinOps)</h3><ul><li>Cost optimization: A single supplier, a single contract, and a single invoice for your transactional database and your analytical data warehouse.</li><li>Snowflake’s elasticity allows you to pay only for the compute and storage resources actually consumed by the Postgres instance, with the ability to easily resize or pause it.</li></ul><p>Enjoy PostgreSQL on Snowflake!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08fa0555e7e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/how-to-migrate-from-postgresql-to-postgresql-on-snowflake-08fa0555e7e1">How to migrate from PostgreSQL to PostgreSQL on Snowflake?</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</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 Install and Use Cortex Code in Snowflake]]></title>
            <link>https://medium.com/snowflake/how-to-install-and-use-cortex-code-in-snowflake-94a24980c92f?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/94a24980c92f</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Thu, 09 Apr 2026 19:01:01 GMT</pubDate>
            <atom:updated>2026-04-09T19:01:01.403Z</atom:updated>
            <content:encoded><![CDATA[<p>Simply put, Cortex Code is Snowflake’s official, native AI programming assistant, custom-designed for data professionals (Data Engineers, Data Analysts, Data Scientists).</p><p>Unlike a general-purpose AI assistant (like mine!) where you have to copy and paste your code or explain your database structure, Cortex Code lives directly in your development environment (via the CLI in VS Code) and is securely connected to your Snowflake account.</p><h4><strong>His main superpowers:</strong></h4><ul><li><strong>Data-oriented code generation: </strong>He excels at writing complex SQL, Python scripts for Snowpark, dbt models, or Streamlit applications. You formulate your request in natural language, and he takes care of the syntax.</li><li><strong>Context-Aware:</strong> Because it’s connected to your Snowflake session, it knows your schemas, table names, and column metadata. If you tell it “Calculate average revenue per customer,” it will know which tables to query without you having to specify the structure.</li><li><strong>Action on your local files: </strong>Since it runs in your VS Code terminal, it doesn’t just generate text in the void: it can read your project, create new files, modify existing code, or write tests directly in your editor.</li><li><strong>Security and Governance:</strong> Everything remains within the secure perimeter of your Snowflake ecosystem. The assistant strictly respects your roles and permissions (RBAC): the AI ​​only has access to the tables and data that your user is authorized to see.</li></ul><h4><strong>In summary</strong></h4><p>This is your development partner. Their goal is to save you valuable time on syntax research, exploring databases you don’t know well, or writing repetitive code, so that you can focus on business logic and architecture.</p><h4><strong>How do I install it?</strong></h4><p>Open a terminal and install the CLI according to your operating system:</p><p>Mac / Linux (including WSL):</p><pre>curl -LsS https://ai.snowflake.com/static/cc-scripts/install.sh | sh</pre><p>Windows (Native): Opens PowerShell and runs:</p><pre>irm https://ai.snowflake.com/static/cc-scripts/install.ps1 | iex</pre><h4><strong>How to create a connection</strong></h4><p>Edit the connections.toml file to check the connections and modify them if necessary.</p><blockquote>code $HOME\.snowflake\connections.toml</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*K06ovAODmnUJMlRh_e2_hQ.png" /></figure><h4><strong>Use it on a daily basis?</strong></h4><p>To launch Cortex Code on a Snowflake account, you must run the following command</p><blockquote>cortex -c connexion_name</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*OawNgukor4fzyxpSInYnPQ.png" /></figure><p>If you wish to launch Cortex Code using a specific template when launching Cortex Code, you can use the following command:</p><blockquote>cortex -m llama3–70b</blockquote><blockquote># or</blockquote><blockquote>cortex — model mistral-large</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*lzR6KOSnSH1HVtRKpJRhmQ.png" /></figure><p>Then ask your questions and select the corresponding choices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*zuKAVwffobEu06xTGSd0eA.png" /></figure><p>To change the model, simply run the following command to use Claude, for example.</p><blockquote>/model nome_model</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*hCq-szWFPq1obNMHYjRxrg.png" /></figure><p>Next, select the Claude model you wish to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*U1z8bjSV4ETlQq-jWXHS1g.png" /></figure><p>Okay, I’ve just selected claude-opus-4–6 as the model for interpreting my prompts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*fMpt8--ggKURjfNVHXRXcQ.png" /></figure><p>The <em>Ctrl+C</em> command kills the current search and returns you to the Cortex Code prompt.</p><p><em>Tying Ctrl+C twice closes Cortex Code.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*E0JELLK9hMCfHgqu4Qx7oQ.png" /></figure><p>Enjoy with Cortex Code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94a24980c92f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/how-to-install-and-use-cortex-code-in-snowflake-94a24980c92f">How to Install and Use Cortex Code in Snowflake</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake Cortex Code in action!]]></title>
            <link>https://medium.com/snowflake/snowflake-cortex-code-in-action-a17855f3eaec?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/a17855f3eaec</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[cortex-code]]></category>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Tue, 17 Mar 2026 19:01:00 GMT</pubDate>
            <atom:updated>2026-03-17T19:01:00.729Z</atom:updated>
            <content:encoded><![CDATA[<p>Cortex Code allows you to analyze your Snowflake platform, create DBT projects, build semantic views, configure Snowflake Intelligence… and much more…</p><p>After enabling multi-region access to benefit from LLM, you must have accountadmin privileges to grant Cortex access to a specific role.</p><pre>GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE votre_role;<br><br>- Example to limit ourselves to European and American AWS servers<br>ALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = &#39;AWS_EU,AWS_US&#39;;<br>ALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = &#39;ANY_REGION&#39;;</pre><p>You can ask him any type of question :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/0*2hnpZgZhxfIEQHYb" /></figure><p>With a really interesting result to consider:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*jiBwUOH-8GpF1Xzm" /></figure><p>Furthermore, it is possible to execute code directly from Cortex Code, or copy/paste code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*CMU-bHIMKHpVNSlm" /></figure><h3>💳 What Actually Incurs Snowflake Credits</h3><p>Even though the agent is free, every action it executes consumes credits through normal Snowflake billing:</p><ul><li><strong>SQL or Python execution</strong> — Any query generated or run by Cortex Code uses <strong>warehouse credits</strong>, exactly as if you ran it manually.</li><li><strong>Cortex AI functions</strong> (AI_COMPLETE, AI_SUMMARIZE, etc.) — Billed <strong>per token</strong> (input + output), with pricing depending on the model. Example: Claude‑4‑Opus is around <strong>12 credits per million tokens</strong>, while smaller models cost significantly less.</li></ul><p><strong>Additional operations</strong>:</p><ul><li>Model validation for Cortex Analyst</li><li>File or project manipulation via the CLI</li><li>Local tool orchestration (git, bash) is free on Snowflake’s side, but any SQL triggered still consumes credits.</li></ul><h3>📊 How to Monitor Usage</h3><p>Costs related to Cortex Code appear in standard Snowflake usage views:</p><ul><li>ACCOUNT_USAGE.QUERY_HISTORY for executed queries</li><li>ACCOUNT_USAGE.CREDIT_USAGE for warehouse consumption</li><li>ACCOUNT_USAGE.AI_MODEL_USAGE for Cortex AI token billing</li></ul><p>Enjoy with Cortex Code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a17855f3eaec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/snowflake-cortex-code-in-action-a17855f3eaec">Snowflake Cortex Code in action!</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proof Of Concept Cortex Agents]]></title>
            <link>https://medium.com/snowflake/proof-of-concept-cortex-agents-3cd17c545a17?source=rss-ed362bfad050------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cd17c545a17</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Pierre-Mickaël Chancrin]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 19:01:01 GMT</pubDate>
            <atom:updated>2026-03-11T19:01:01.223Z</atom:updated>
            <content:encoded><![CDATA[<p>This proof of concept (POC) aims to enable querying data using natural language.</p><p>A Snowflake Cortex POC serves to quickly demonstrate, within a limited scope, how generative AI can create value within the company while remaining in a secure and governed environment.</p><p>It allows for measuring the real impact on business use cases, verifying technical feasibility within the existing ecosystem, and evaluating costs before large-scale deployment.</p><p>Thanks to native integration in Snowflake, data remains protected, models are immediately usable, and industrialization is facilitated.<br>A well-executed POC therefore provides proof of value, proof of feasibility, and proof of industrialization, which helps in deciding where to invest and how to manage the use of AI within the organization.</p><p>First, create the POC tables.</p><pre>USE ROLE ACCOUNTADMIN;</pre><pre>--This command allows the use of templates located in any AWS region in Europe.<br><br>-- This is essential when hosted in Paris to use Cortex.<br><br>ALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = &#39;AWS_EU&#39;;</pre><pre>-- (Optional) If you want to be 100% sure it works, open it to the US as well:<br>-- ALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = &#39;ANY_REGION&#39;;<br><br>USE ROLE ACCOUNTADMIN;<br>USE DATABASE POC_COCO;<br>USE SCHEMA RETAIL;<br>-- 1. Look carefully at the result of this command<br>LIST @POC_COCO.RETAIL.COCO_STAGE;<br>SELECT CURRENT_REGION();<br>-- 1. We take on the role of super-admin to have the right to do everything<br>USE ROLE ACCOUNTADMIN;<br>-- 2. The system role &quot;CORTEX_USER&quot; is assigned to your current user.<br>-- This is THE critical line that is often missing<br>GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE ACCOUNTADMIN;<br>-- (Optional) If you sometimes use SYSADMIN, also grant it the rights<br>GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE SYSADMIN;<br>-- 3. We ensure that the role has access to the POC objects<br>GRANT USAGE ON DATABASE POC_COCO TO ROLE ACCOUNTADMIN;<br>GRANT USAGE ON SCHEMA POC_COCO.RETAIL TO ROLE ACCOUNTADMIN;<br>-- 4. The right to READ the YAML file is granted in the internship.<br>GRANT READ ON STAGE POC_COCO.RETAIL.COCO_STAGE TO ROLE ACCOUNTADMIN;<br>-- 5. We grant permission to read the tables (so that the generated SQL can execute).<br>GRANT SELECT ON ALL TABLES IN SCHEMA POC_COCO.RETAIL TO ROLE ACCOUNTADMIN;<br>-- 1. Environment configuration<br>CREATE DATABASE IF NOT EXISTS POC_COCO;<br>CREATE SCHEMA IF NOT EXISTS RETAIL;<br>USE DATABASE POC_COCO;<br>USE SCHEMA RETAIL;<br>-- 2. Customer Table (Dimension)<br>CREATE OR REPLACE TABLE CLIENTS (<br>    CLIENT_ID INT,<br>    NOM STRING,<br>    SEGMENT STRING, -- ex: VIP, Standard<br>    PAYS STRING<br>);<br>INSERT INTO CLIENTS VALUES<br>(101, &#39;Entreprise A&#39;, &#39;VIP&#39;, &#39;France&#39;),<br>(102, &#39;Startup B&#39;, &#39;Standard&#39;, &#39;Allemagne&#39;),<br>(103, &#39;Grand Groupe C&#39;, &#39;VIP&#39;, &#39;France&#39;),<br>(104, &#39;PME D&#39;, &#39;Standard&#39;, &#39;Espagne&#39;);<br>-- 3. Sales Table (Facts)<br>CREATE OR REPLACE TABLE VENTES (<br>    VENTE_ID INT,<br>    DATE_VENTE DATE,<br>    CLIENT_ID INT, -- Clé étrangère<br>    PRODUIT STRING,<br>    MONTANT FLOAT<br>);<br>INSERT INTO VENTES VALUES<br>(1, &#39;2024-01-10&#39;, 101, &#39;Licence Soft&#39;, 5000.00),<br>(2, &#39;2024-01-12&#39;, 102, &#39;Support&#39;, 500.00),<br>(3, &#39;2024-01-15&#39;, 103, &#39;Consulting&#39;, 15000.00),<br>(4, &#39;2024-02-01&#39;, 101, &#39;Maintenance&#39;, 1200.00),<br>(5, &#39;2024-02-05&#39;, 104, &#39;Licence Soft&#39;, 4800.00);<br>-- 4. Creation of the Stage to store the YAML file (Coco&#39;s brain)<br>CREATE OR REPLACE STAGE COCO_STAGE;</pre><p>Now create the following file: retail_semantic_model.yaml and push it into the stage</p><pre>name: retail_sales_model<br>tables:<br>  - name: VENTES<br>    base_table:<br>      database: POC_COCO<br>      schema: RETAIL<br>      table: VENTES<br>    columns:<br>      - name: MONTANT<br>        synonyms: [&quot;ca&quot;, &quot;chiffre d&#39;affaires&quot;, &quot;revenu&quot;]<br>        aggregation: sum<br>      - name: DATE_VENTE<br>        synonyms: [&quot;date&quot;, &quot;jour&quot;]<br>      - name: PRODUIT<br>        synonyms: [&quot;article&quot;, &quot;item&quot;]<br>      - name: CLIENT_ID<br>        hidden: true<br>      - name: CLIENTS<br>    base_table:<br>      database: POC_COCO<br>      schema: RETAIL<br>      table: CLIENTS<br>    columns:<br>      - name: PAYS<br>        synonyms: [&quot;région&quot;, &quot;territoire&quot;]<br>      - name: SEGMENT<br>        synonyms: [&quot;type&quot;, &quot;catégorie&quot;]<br>        sample_values: [&quot;VIP&quot;, &quot;Standard&quot;]<br>      - name: NOM<br>        synonyms: [&quot;client&quot;, &quot;société&quot;]<br>      - name: CLIENT_ID<br>        hidden: true<br>relationships:<br>  - name: ventes_to_clients<br>    left_table: VENTES<br>    right_table: CLIENTS<br>    join_type: left_outer<br>    relationship_columns:<br>      - left_column: CLIENT_ID<br>        right_column: CLIENT_ID</pre><p>Next, create a Streamlit application that we will call Cortex Analyst Demo; here is the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*3H2RIakYOztI1qjx" /></figure><pre>import streamlit as st<br>from snowflake.snowpark.context import get_active_session</pre><pre># — — Configuration — -<br>st.set_page_config(layout=”wide”)<br>st.title(“POC Cortex Code”)<br>st.caption(“Mode : Prompt Engineering (Sans fichier YAML)”)<br>session = get_active_session()<br># — — THE BRAIN (We replace the YAML with this text) — -<br># This is where we explain the data model to LLM<br>SCHEMA_CONTEXT = “””<br>You are a Snowflake SQL expert.<br>Your goal is to generate a valid SQL query to answer the question.<br>Here is the data schema available in the POC_COCO.RETAIL database:<br>1. SALES Table (Acts)<br>- Columns: SALE_ID, SALE_DATE, CUSTOMER_ID, PRODUCT, AMOUNT<br>- ‘Revenue’ or ‘TO’ corresponds to the sum of the AMOUNT column.<br>- Join: This table is linked to CUSTOMERS via the CUSTOMER_ID column.<br>2. CUSTOMERS Table (Dimension)<br>- Columns: CUSTOMER_ID, NAME, SEGMENT, COUNTRY<br>- Possible segments: ‘VIP’, ‘Standard’<br>- Possible countries: ‘France’, ‘Germany’, ‘Spain’<br>Strict rules:<br>- Provide ONLY the SQL code. No text before, no text after.<br>- Do not use Markdown tags (no ```sql). — Always perform explicit joins (JOINs) on CLIENT_ID if necessary.<br>- For amount aggregations, use SUM(AMOUNT).<br>“””<br>def generate_sql_with_llm(question):<br> “””<br>Use the Llama 3 model (available in Paris) to generate the SQL<br> “””<br> # Construction of the complete prompt<br> prompt = f”””<br> {SCHEMA_CONTEXT}<br> <br> User question : “{question}”<br> <br> Code SQL :<br> “””<br> <br> # Escaping apostrophes for the Snowflake SQL query<br> prompt_safe = prompt.replace(“‘“, “‘’”)<br> <br># Call to Cortex Complete (Works everywhere)<br># We use ‘mistral-large’ or ‘llama3–70b’ which are excellent for SQL<br> sql_cmd = f”SELECT SNOWFLAKE.CORTEX.COMPLETE(‘mistral-large’, ‘{prompt_safe}’) as RESPONSE”<br> <br> try:<br> result = session.sql(sql_cmd).collect()<br> generated_text = result[0][‘RESPONSE’]<br> <br> # Security cleanup (in case LLM adds markdown)<br> clean_sql = generated_text.replace(“```sql”, “”).replace(“```”, “”).strip()<br> <br> # Remove the final semicolon if it exists (Snowpark sometimes doesn’t like that)<br> if clean_sql.endswith(‘;’):<br> clean_sql = clean_sql[:-1]<br> <br> return clean_sql<br> <br> except Exception as e:<br> return f”Erreur : {str(e)}”<br># — — INTERFACE — -<br># Historique<br>if “messages” not in st.session_state:<br> st.session_state.messages = []<br>for message in st.session_state.messages:<br> with st.chat_message(message[“role”]):<br> if “sql” in message:<br> st.code(message[“sql”], language=”sql”)<br> st.dataframe(message[“data”])<br> else:<br> st.write(message[“content”])<br># Input area<br>if request := st.chat_input(“Your question (e.g., What is the revenue per country?) ?)”):<br> <br> st.session_state.messages.append({“role”: “user”, “content”: request})<br> with st.chat_message(“user”):<br> st.write(request)<br>with st.chat_message(“assistant”):<br> with st.spinner(“Génération du SQL (Mistral Large @ Paris)…”):<br> <br> # 1. Generation<br> sql_code = generate_sql_with_llm(request)<br> <br> # Checking if it’s a technical error<br> if sql_code.startswith(“Error”):<br> st.error(sql_code)<br> else:<br> st.markdown(“**SQL generated:**”)<br> st.code(sql_code, language=”sql”)<br> <br> # 2. Exécution<br> try:<br> df_result = session.sql(sql_code)<br> st.markdown(“**Résultat :**”)<br> st.dataframe(df_result)<br> <br> st.session_state.messages.append({<br> “role”: “assistant”, <br> “content”: “Voici le résultat :”,<br> “sql”: sql_code,<br> “data”: df_result<br> })<br> except Exception as e:<br> st.error(“Error executing generated SQL.”)<br> st.warning(f”Message d’erreur : {e}”)</pre><p>— -</p><p>Here are some typical questions you can ask the Snowflake Cortex Text-to-SQL Proof of Concept (POC):<br>Level 1: Simple Aggregations<br>1. “What is the total revenue?”<br>Expected result: 26,500<br>Calculation: 5000 + 500 + 15000 + 1200 + 4800</p><p>2. “How many sales were made in total?”<br>Expected result: 5</p><p>3. “What is the average sale amount?”<br>Expected result: 5,300<br>Calculation: 26,500 / 5</p><p>— -</p><p>Level 2: Filters (Conditions)<br>4. “What is the revenue for the ‘Software License’ product?”<br>Expected result: 9,800<br>Details: Sale #1 (5000) + Sale #5 (4800)</p><p>5. “Show me the sales exceeding €2,000.”<br>Expected result: 3 lines.</p><p>Software License (5,000)<br>Consulting (15,000)<br>Software License (4,800)</p><p>6. “What is the revenue generated in January 2024?”<br>Expected result: 20,500<br>Details: Sum of sales on January 10, 12, and 15 (5,000 + 500 + 15,000). February sales (1,200 and 4,800) are excluded.</p><p>— -</p><p>Level 3: Joins (The Critical Test)<br>7. “What is the revenue per country?”</p><p>Expected result:<br>France: 21,200 (Customers 101 and 103)<br>Spain: 4,800 (Customer 104)<br>Germany: 500 (Customer 102)</p><p>8. “What is the total sales amount for VIP customers?”<br>Expected result: 21,200<br>Explanation: The VIP customers are “Company A” (101) and “Large Group C” (103). Their combined purchases total 21,200.</p><p>9. “Give me the list of customers in France.”<br>Expected result: 2 lines.</p><p>Company A<br>Large Group C</p><p>— -</p><p>Level 4: Top and Sort<br>10. “Which product is the best-selling?”<br>Expected result: Consulting (with €15,000)<br>Trick: ‘Software License’ has 2 sales, but the total is only €9,800. ‘Consulting’ has only 1 sale, but for €15,000.</p><p>11. “What are the 3 largest clients by revenue?”<br>Expected result:</p><p>Large Group C (€15,000)<br>Company A (€6,200)<br>SME D (€4,800)</p><p>(Startup B is last with €500, so it does not appear in the top 3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*oKz8BZ6t23XcaRqE" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cd17c545a17" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/proof-of-concept-cortex-agents-3cd17c545a17">Proof Of Concept Cortex Agents</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>