<?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 Yarden Sheinson on Medium]]></title>
        <description><![CDATA[Stories by Yarden Sheinson on Medium]]></description>
        <link>https://medium.com/@yarden.sheinson_75415?source=rss-6bdef5ac87ed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BCl_R_SdxNKhfez3</url>
            <title>Stories by Yarden Sheinson on Medium</title>
            <link>https://medium.com/@yarden.sheinson_75415?source=rss-6bdef5ac87ed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 06:32:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yarden.sheinson_75415/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[This Took 5 Minutes to Set Up — and Now Business Users Query Snowflake Without SQL]]></title>
            <link>https://medium.com/snowflake/this-took-5-minutes-to-set-up-and-now-business-users-query-snowflake-without-sql-d1e4e481326d?source=rss-6bdef5ac87ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1e4e481326d</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Yarden Sheinson]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 15:03:12 GMT</pubDate>
            <atom:updated>2026-01-19T15:03:12.939Z</atom:updated>
            <content:encoded><![CDATA[<h3>This Took 5 Minutes to Set Up — and Now Business Users Query Snowflake Without SQL</h3><p>I didn’t expect this to land the way it did.</p><p>After walking a few customers through the setup, I kept hearing the same reaction:</p><p><em>“Wait… that’s it? We’re done already?”</em></p><p>Yes. That’s it.</p><p>In under five minutes, they had business users asking questions like <em>“Which warehouse costs the most?”</em> and <em>“Who owns this schema?”</em> — in plain English — with no SQL, no dashboards, and no analytics ticket.</p><p>What surprised me even more?</p><p>They didn’t just use it. They started extending it themselves.</p><p>This was a collaborative effort with my coworkers <strong>Ed Crean</strong> and <strong>Jithin Chacko</strong>, later evolved based on customer feedback.</p><h3>The Real Problem (it’s not SQL)</h3><p>Most teams already <em>have</em> Snowflake account data.</p><p>The problem is access:</p><ul><li>Business users don’t write SQL</li><li>Analysts don’t want to babysit ACCOUNT_USAGE questions</li><li>Dashboards never quite answer the <em>one</em> follow-up someone cares about</li></ul><p>So questions pile up. Slack messages multiply. And everyone wastes time running almost the same queries again and again.</p><p>We wanted a way for <strong>non-technical users to safely self-serve account insights — </strong>without opening the door to bad queries, hallucinated tables, or runaway costs.</p><h3>The Insight: Guardrails Beat Intelligence</h3><p>The breakthrough wasn’t “better AI.” It was <strong>constraints</strong>.</p><p>Instead of letting an LLM freely explore Snowflake, we gave it:</p><ul><li>A <strong>small, explicit set of tables</strong></li><li>Clear definitions for each column</li><li>Pre-verified query patterns for common questions</li></ul><p>In Snowflake, this is done with a <strong>Semantic Model</strong>— a simple YAML file that acts as guardrails.</p><p>Think of it like this: <em>The AI isn’t smart because it knows everything. It’s smart because it knows </em>exactly what it’s allowed to answer.</p><h3>What You’re Actually Building</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*aJ2BZ4_MyPhIeQHQaDC6qw.png" /></figure><p>You’re creating a <strong>Snowflake AI agent</strong> that:</p><ol><li>Accepts plain-English questions</li><li>Translates them into SQL using Cortex Analyst</li><li>Executes only vetted queries against ACCOUNT_USAGE</li><li>Returns answers users can trust</li></ol><p>The best part:</p><p>Here you already get a <strong>ready-to-use Semantic Model</strong> for Snowflake’s ACCOUNT_USAGE views. You don’t need to design one from scratch.</p><h3>The Part That Surprised Me</h3><p>I expected people to <em>use</em> the agent.</p><p>I didn’t expect them <strong>to extend it</strong>.</p><p>The YAML turned out to be readable enough that teams:</p><ul><li>Added their own questions</li><li>Customized patterns for internal language</li><li>Took ownership instead of filing tickets</li></ul><p>That’s when I knew this worked.</p><p>Not because it was fast to deploy — but because it scaled <em>without</em> becoming another tool people depended on analytics for.</p><h3>The Takeaway</h3><p>If you want business users to self-serve Snowflake account insights without SQL:</p><ol><li>Use a constrained Semantic Model</li><li>Create a Snowflake agent</li><li>Let people ask questions in plain English</li></ol><p><strong>Setup time:</strong> ~5 minutes<br><strong>Time saved:</strong> hours every week</p><p>The Semantic Model YAML and full instructions are included above.</p><p>If you try this, I’d love to hear:</p><p><strong>What’s the first Snowflake question your team would ask if SQL wasn’t required?</strong></p><h3><strong>Practical Steps: How to Set It Up</strong></h3><p><strong>Ready to try it yourself?</strong></p><p>Below are the full, step-by-step instructions to get a Snowflake AI agent up and running with the pre-built Semantic Model. Follow these, and you’ll be answering plain-English questions in minutes.</p><p>Once your agent is live, your team can immediately ask questions like:</p><ul><li><em>“Which warehouse costs the most?”</em></li><li><em>“Who owns the schema PUBLIC?”</em></li><li><em>“What tables haven’t been accessed in the last 3 days?”</em> 🔍</li></ul><p>These are just a few examples — the full set of 20+ questions is listed below.</p><p><strong>Step 1 — </strong>Download the attached yaml file —</p><blockquote><a href="https://github.com/sfc-gh-ysheinson/semantic_model/blob/main/snowflake_admin_semantic_model.yaml">https://github.com/sfc-gh-ysheinson/semantic_model/blob/main/snowflake_admin_semantic_model.yaml</a></blockquote><blockquote>*This yaml file can be reused in any snowflake account since Account usage semantics stays the same</blockquote><p><strong>Step 2 — </strong>Pre Requisites to enable <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/snowflake-intelligence#set-up-sf-intelligence">Snowflake Intelligence</a> in your account:</p><pre>CREATE DATABASE IF NOT EXISTS snowflake_intelligence;<br>GRANT USAGE ON DATABASE snowflake_intelligence TO ROLE PUBLIC;<br><br>CREATE SCHEMA IF NOT EXISTS snowflake_intelligence.agents;<br>GRANT USAGE ON SCHEMA snowflake_intelligence.agents TO ROLE PUBLIC;<br><br>CREATE STAGE SEMANTHIC;<br>-- UPLOAD THE ATTACHED YAML FILE INTO A STAGE + ENABLE DIRECTORY<br>LS @SEMANTHIC;<br><br>-- Create a role<br>CREATE ROLE &lt;role&gt;;<br>-- Grant database usage (required to access the database)<br>GRANT USAGE ON DATABASE snowflake_intelligence TO ROLE &lt;role&gt;;<br>-- Grant schema usage<br>GRANT USAGE ON SCHEMA snowflake_intelligence.agents TO ROLE &lt;role&gt;;<br>-- Grant monitor privilege on database<br>GRANT MONITOR ON DATABASE snowflake_intelligence TO ROLE &lt;role&gt;;<br>-- Grant agent creation<br>GRANT CREATE AGENT ON SCHEMA snowflake_intelligence.agents TO ROLE &lt;role&gt;;<br>-- Grant access to SNOWFLAKE database and ACCOUNT_USAGE schema<br>GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE &lt;role&gt;;</pre><p><strong>Step 3 —</strong> Copy / upload manually the Yaml file with Semantic model into an internal stage:</p><p>Catalog → Database Explorer → Navigate to the stage created→ + Files (right corner) → Upload the snowflake_semantic_model.yaml file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cpVR5dG9KN42dakRIpvKjQ.png" /></figure><p><strong>Step 4 — </strong>Snowsight UI → AI &amp; ML → Agents → Create Agent, Enter details shown below or any name you prefer and click Create agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*eEQwEji4H6_zsX0ht51ppQ.png" /></figure><p><strong>Step 5 — </strong>Click on the newly created Agent → Top right Edit → Give a brief description about the agent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*X6zrP8TeqT7gWvmiF2-7pg.png" /></figure><blockquote>You can copy paste the below:<strong> <em><br> </em></strong><em>This agent, built using Snowflake Intelligence and powered by Cortex Analyst, serves as an Al-driven assistant for account usage insights. It translates natural-language queries about your Snowflake account usage data into accurate SQL via the Cortex Analyst semantic model, then securely executes them to deliver actionable responses. Built atop Snowflake’s enterprise-grade Cortex framework, the agent ensures precise, governed, and seamless analytics- no SQL required.</em></blockquote><p><strong>Step 6 — </strong>Click on Tools → Press + Add on Cortex Analyst → Select the Database, Schema &amp; Internal Stage where the Semantic yaml is present:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*Ns4iWB0J0ESZKCuTF5Ke1Q.png" /></figure><p><strong>Step 7 — </strong>You will need a <strong>Description</strong> for the tool, you could generate it using ‘Generate with Cortex’ button or copy paste the attached here, or use a custom one , once done press on Add and Save the Agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*Ku50hL95dKFnIUkfmyGCbw.png" /></figure><blockquote>The Snowflake Governance and Security Semantic Model provides end-to-end visibility into access control, object ownership, storage utilization, and operational activity across a Snowflake account.<br> This model enables comprehensive analysis across four key domains:</blockquote><blockquote>1. Access Control &amp; Security: Track role hierarchies, user-to-role assignments, and privilege inheritance. Answer questions like “Which users can access table X?”, “What privileges does user Y have in database Z?”, and “What roles are unassigned?” The model supports recursive role hierarchy traversal to resolve inherited privileges across multiple role levels.</blockquote><blockquote>2. Object Ownership &amp; Governance: Identify current object owners, ownership history, and permission grants across schemas, tables, and views. Query ownership patterns, find objects by owner, and audit permission changes over time.</blockquote><blockquote>3. Storage &amp; Capacity Management: Analyze storage consumption by database, schema, or table. Track table sizes (bytes), row counts, and identify the largest objects. Support capacity planning and cost optimization through storage metrics.</blockquote><blockquote>4. Audit Trail &amp; Compliance: Track all DDL operations (CREATE, ALTER, DROP) with full context of who performed the action, when, and with which role. Support compliance requirements by providing complete audit history of schema changes and access pattern analysis.</blockquote><blockquote>All tables reside in the SNOWFLAKE database, ACCOUNT_USAGE schema, forming a complete governance, security, and operational tracking system. The model supports natural language queries ranging from simple ownership lookups to complex role hierarchy analysis and user privilege resolution across multiple databases.</blockquote><p><strong>Step 8 — </strong>Click on Snowflake Intelligence → Agents → your Agent Name</p><p><strong>Step 9 —</strong> Start asking questions:</p><p>Go to: <strong>Snowflake Intelligence → Agents → Account Usage</strong></p><h3><strong>You’re live.</strong></h3><h3>Example Questions the Agent Can Answer</h3><p>Once enabled, teams immediately start asking questions like:</p><p><strong>A. Object Analysis &amp; Storage / Utilization 💾</strong></p><ol><li>Largest Tables — “What is the largest table in the system?”</li><li>Schema Ownership — “Who owns the schema PUBLIC?”</li><li>Role Ownership Inventory — “Which 5 roles own the most objects, and how many objects does each own?”</li><li>Recent Object Creation — “What objects were created in the last 7 days?”</li><li>Schema Storage Usage — ”Which schemas use the most storage?”</li><li>Database Storage Usage — “Show me storage usage by database”</li><li>Modification Tracking — “Show me tables or schemas altered in the last 7 days”</li></ol><p><strong>B. Roles Privileges 🔐</strong></p><ol><li>Ownership Privileges — “What roles have ownership privileges?”</li><li>Unassigned Roles — “What roles are unassigned?”</li><li>User/Role Privileges on Objects — “Which tables does user YSHEINSON have WRITE privileges on?” “Which objects (tables, views, stages, warehouses) does a user or role have privileges on, including inherited privileges?”</li><li>Object-Specific Privilege Checks — “Which roles and users have a specific privilege on a given object (e.g., SELECT on table XX)?”</li></ol><p><strong>C. Observability &amp; Auditing / Activity Monitoring 🔍</strong></p><ol><li>Audit Trail — “Show me all DDL operations performed by SYSADMIN this week”. “Show me all CREATE and DROP operations from the last 30 days”</li><li>Unused Warehouses — <em>“Which warehouses have not been used in the last 3 days?”</em></li><li>Long-Running Queries — “Which queries ran longer than 1 hour in the last 48 hours?”</li><li>Unused — “Which tables, views, or stages have never been accessed in the last 3 days?”</li><li>Rarely Accessed Objects — “Which tables, views, or stages haven’t been accessed in the last 3 days?”</li></ol><p><strong>D. Warehouse Cost &amp; Performance 💰</strong></p><ol><li>Credit Consumption — “How many credits did each warehouse consume in the last 30 days?”</li><li>Warehouse Consumption — “Which warehouses cost the most?”</li><li>Usage Trends — “Show me daily warehouse credit usage for the last 7 days”</li><li>Warehouse Load Statistic — “Show me warehouse load and query queue statistics”</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1e4e481326d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/this-took-5-minutes-to-set-up-and-now-business-users-query-snowflake-without-sql-d1e4e481326d">This Took 5 Minutes to Set Up — and Now Business Users Query Snowflake Without SQL</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[ACCOUNT_USAGE Consolidation]]></title>
            <link>https://medium.com/snowflake/account-usage-consolidation-97ca79e3e4e6?source=rss-6bdef5ac87ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/97ca79e3e4e6</guid>
            <category><![CDATA[finops]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[cost-optimization]]></category>
            <dc:creator><![CDATA[Yarden Sheinson]]></dc:creator>
            <pubDate>Tue, 23 Dec 2025 15:02:28 GMT</pubDate>
            <atom:updated>2025-12-23T17:45:39.500Z</atom:updated>
            <content:encoded><![CDATA[<h3>Snowflake ACCOUNT_USAGE Consolidation: A Step-by-Step Guide</h3><p><strong>Overview — </strong>Centralize Account Usage from multiple Snowflake accounts into one monitoring account. To consolidate multi-account usage data, the process involves three key steps:</p><ul><li><strong>1st,</strong> within each Source Account, a scheduled process copies the slow SNOWFLAKE.ACCOUNT_USAGE data into a <strong>fast, user-owned table</strong>.</li><li><strong>2nd,</strong> that prepared data is shared with the <strong>Central Monitoring Account</strong> using a <strong>Secure Data Share</strong> or an <strong>Internal Marketplace Listing</strong>.</li><li><strong>3rd,</strong> the Central Account subscribes to the share and runs a dedicated job to pull the data from the read-only shared databases into its own single, comprehensive master table for organization-wide analysis.</li></ul><p><strong>Motivation</strong>:</p><ul><li>Client wants to create time series analyses &gt; 1yr. Current limitations are ACCOUNT_USAGE is only stored for 1yr</li><li>Client needs to persist all LOGIN_HISTORY or access related data for compliance</li><li>Client wants to create separate tables to build or share secure views across the organization for central reporting</li><li>The required premium view isn’t available in the Organization Usage schema, so these views must be manually consolidated to run dashboards or further analyses.</li></ul><p><strong>Framework:</strong></p><ul><li>There are several ways to implement this solution. This approach uses OBJECT_CONSTRUCT() to guard against schema drift</li><li>This stored procedure should live in the COMMON schema as a UTILITY (The attached code is written in JavaScript, but it can be easily adjusted to your preferred language)</li><li>We can schedule this process as a TASK to execute periodically</li><li>We can also have a child task to export the data to Cloud storage</li></ul><p><strong>Prerequisites</strong>:</p><ul><li>Permissions to access the schemas ACCOUNT_USAGE / ORGANIZATION_USAGE</li><li>Permissions to create share on the account</li><li>Internal marketplace permissions</li></ul><p><strong>Required arguments:</strong></p><ul><li>AUDIT_SCHEMA_NAME : ACCOUNT_USAGE or ORGANIZATION_USAGE</li><li>AUDIT_VIEW_NAME : View / object eg. QUERY_HISTORY, LOGIN_HISTORY</li><li>WATERMARK : The date/timestamp column used in the AUDIT_VIEW_NAME for incremental loads</li><li>DAYS_LOOKBACK : Note this is a parameter to calculate how far back in history to load</li><li>DESTINATION_DB : The name of your destination audit database</li><li>DESTINATION_SCHEMA : The name of your destination audit schema</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*36-icd-EmOay77ZtGLEAVA.png" /></figure><p><strong>Scripts to run:</strong></p><pre>USE ROLE ACCOUNTADMIN; <br>USE DATABASE YS_DEMO_DB;<br>USE SCHEMA YS_DEMO_SCHEMA;</pre><pre>CREATE OR REPLACE PROCEDURE YS_DEMO_DB.YS_DEMO_SCHEMA.PERSIST_SNOWFLAKE_USAGE_VIEWS(<br>  AUDIT_SCHEMA_NAME__ VARCHAR<br>  , AUDIT_VIEW_NAME__ VARCHAR<br>  , WATERMARK__ VARCHAR<br>  , DAYS_LOOKBACK__ VARCHAR<br>  , DESTINATION_DB__ VARCHAR<br>  , DESTINATION_SCHEMA__ VARCHAR)<br>RETURNS VARCHAR<br>LANGUAGE JAVASCRIPT<br>AS<br>$$<br>var sqlcmd = &quot;&quot;; // Declare &#39;sqlcmd&#39; variable globally within the script scope<br><br>try {<br>    // Persists all organization usage views into a table for auditing, additional reporting, and timeseries.<br>    // Note must have permissions to query the ACCOUNT_USAGE or ORGANIZATION_USAGE views<br>    var AUDIT_TABLE_NAME__ = DESTINATION_DB__ + &quot;.&quot; + DESTINATION_SCHEMA__ + &quot;.&quot; + AUDIT_SCHEMA_NAME__ + &quot;_&quot; + AUDIT_VIEW_NAME__ ;<br>    var STAGE_TABLE_NAME__ = AUDIT_VIEW_NAME__ + &quot;_STAGE&quot;;<br>    var result = &#39;Success loading: &#39; + AUDIT_TABLE_NAME__;  <br>    <br>    // Create audit table if not exists<br>    sqlcmd = &quot;CREATE TRANSIENT TABLE IF NOT EXISTS &quot; + AUDIT_TABLE_NAME__ <br>        + &quot; (LOG_ID VARCHAR, PAYLOAD VARIANT, _TIME_INSERTED TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP())&quot;;<br>    var cmdexec = snowflake.createStatement( { sqlText: sqlcmd } );<br>    var res = cmdexec.execute();<br><br><br>    // Create the stage table to insert and export<br>    sqlcmd = &quot;CREATE OR REPLACE TRANSIENT TABLE &quot; + STAGE_TABLE_NAME__ + &quot; AS \n&quot; +<br>         &quot;SELECT \n&quot; +<br>         &quot;    SHA2_HEX(OBJECT_CONSTRUCT(*)::VARCHAR) AS LOG_ID \n&quot; +<br>         &quot;    , OBJECT_CONSTRUCT(*) AS PAYLOAD \n&quot; +<br>         &quot;    , CURRENT_TIMESTAMP() AS _TIME_INSERTED \n&quot; +<br>         &quot;FROM \n&quot; +<br>         &quot;    SNOWFLAKE.&quot; + AUDIT_SCHEMA_NAME__+ &quot;.&quot; + AUDIT_VIEW_NAME__ + &quot;\n&quot; +<br>         &quot;WHERE 1=1 \n&quot; +<br>         &quot;AND LOG_ID NOT IN (SELECT LOG_ID FROM &quot; + AUDIT_TABLE_NAME__ + &quot; ) \n&quot; +<br>         &quot;AND &quot; + WATERMARK__ + &quot; &gt;= DATEADD(&#39;DAYS&#39;, &quot; + DAYS_LOOKBACK__ + &quot;, CURRENT_TIMESTAMP())&quot;;<br>    var cmdexec = snowflake.createStatement( { sqlText: sqlcmd } );<br>    var res = cmdexec.execute();<br><br>    // Insert into the audit table<br>    sqlcmd = &quot;INSERT INTO &quot; + AUDIT_TABLE_NAME__ + &quot; SELECT LOG_ID, PAYLOAD, _TIME_INSERTED FROM &quot; + STAGE_TABLE_NAME__ ;<br>    var cmdexec = snowflake.createStatement( { sqlText: sqlcmd } );<br>    var res = cmdexec.execute();<br>    <br>    // Insert into the audit table<br>    var sqlInsertIntoAuditTable = &quot;INSERT INTO &quot; + AUDIT_TABLE_NAME__ + &quot; SELECT LOG_ID, PAYLOAD, _TIME_INSERTED FROM &quot; + STAGE_TABLE_NAME__ ;<br>    var cmdexec = snowflake.createStatement( { sqlText: sqlInsertIntoAuditTable } );<br>    var res = cmdexec.execute();<br>    }<br>catch (err)  {<br>    var result =  &quot;Failed: Code: &quot; + err.code + &quot;\n  State: &quot; + err.state;<br>    result += &quot;\n  Message: &quot; + err.message;<br>    result += &quot;\nStack Trace:\n&quot; + err.stackTraceTxt;<br>    result += &quot;\nFailed SQL Command:\n&quot; + sqlcmd; // Corrected line<br>    }<br>return result<br>$$;</pre><pre>-- Capture ACCOUNT_USAGE -ACCESS_HISTORY<br>CALL YS_DEMO_DB.YS_DEMO_SCHEMA.PERSIST_SNOWFLAKE_USAGE_VIEWS(<br>  &#39;ACCOUNT_USAGE&#39;                   --AUDIT_SCHEMA_NAME__<br>  , &#39;ACCESS_HISTORY&#39;                 --AUDIT_VIEW_NAME__<br>  , &#39;QUERY_START_TIME&#39;               --WATERMARK__<br>  , &#39;-10&#39;                           --DAYS_LOOKBACK__<br>  , &#39;YS_DEMO_DB&#39;                    --DESTINATION_DB__<br>  , &#39;ACCOUNT_AUDIT&#39;);               --DESTINATION_SCHEMA__<br><br>    --VALIDATION PHASE:<br>    --SOURCE<br>    SELECT SUM(1) FROM SNOWFLAKE.ACCOUNT_USAGE.ACCESS_HISTORY;<br>    --TARGET<br>    SELECT SUM(1) FROM YS_DEMO_DB.ACCOUNT_AUDIT.ACCOUNT_USAGE_ACCESS_HISTORY;</pre><pre>-- Capture ACCOUNT_USAGE - LOGIN_HISTORY<br>CALL YS_DEMO_DB.YS_DEMO_SCHEMA.PERSIST_SNOWFLAKE_USAGE_VIEWS(<br>  &#39;ACCOUNT_USAGE&#39;                   --AUDIT_SCHEMA_NAME__<br>  , &#39;LOGIN_HISTORY&#39;                 --AUDIT_VIEW_NAME__<br>  , &#39;EVENT_TIMESTAMP&#39;               --WATERMARK__<br>  , &#39;-10&#39;                           --DAYS_LOOKBACK__<br>  , &#39;YS_DEMO_DB&#39;                    --DESTINATION_DB__<br>  , &#39;ACCOUNT_AUDIT&#39;);               --DESTINATION_SCHEMA__<br><br>    --VALIDATION PHASE:<br>    --SOURCE<br>    SELECT SUM(1) FROM SNOWFLAKE.ACCOUNT_USAGE.LOGIN_HISTORY;<br>    --TARGET<br>    SELECT SUM(1) FROM YS_DEMO_DB.ACCOUNT_AUDIT.ACCOUNT_USAGE_LOGIN_HISTORY;</pre><p>You can run the same for any account_usage view you’d like to add to your flow:</p><pre>-- Capture ORGANIZATION_USAGE - WAREHOUSE_METERING_HISTORY<br>CALL YS_DEMO_DB.YS_DEMO_SCHEMA.PERSIST_SNOWFLAKE_USAGE_VIEWS(<br>  &#39;ORGANIZATION_USAGE&#39;              --AUDIT_SCHEMA_NAME__<br>  , &#39;WAREHOUSE_METERING_HISTORY&#39;    --AUDIT_VIEW_NAME__<br>  , &#39;START_TIME&#39;                    --WATERMARK__<br>  , &#39;-10&#39;                           --DAYS_LOOKBACK__<br>  , &#39;YS_DEMO_DB&#39;                    --DESTINATION_DB__<br>  , &#39;AUDIT_ORGS&#39;);                  --DESTINATION_SCHEMA__<br><br>  --VALIDATION PHASE:<br>    --SOURCE<br>    SELECT SUM(1) FROM SNOWFLAKE.ORGANIZATION_USAGE.WAREHOUSE_METERING_HISTORY;<br>    --TARGET<br>    SELECT SUM(1) FROM YS_DEMO_DB.AUDIT_ORGS.ORGANIZATION_USAGE_WAREHOUSE_METERING_HISTORY;</pre><p>Once the local tables are created and populated, you create and configure the share. This is when the share is performed.</p><h3>Set Up Secure Data Sharing (Provider -Source Account)</h3><h4>1. Create the Share Object</h4><p>This object will be used to bundle the tables you want to share.</p><pre>USE ROLE ACCOUNTADMIN;<br>-- 1. Create the Share object<br>CREATE OR REPLACE SHARE USAGE_DATA_SHARE;</pre><h4>2. Grant Privileges on Database and Schema</h4><p>You need to grant the share access to the database and schema that contain your copied tables.</p><pre>-- 2. Grant USAGE on the database and schema to the Share<br>GRANT USAGE ON DATABASE YS_DEMO_DB TO SHARE USAGE_DATA_SHARE;<br>GRANT USAGE ON SCHEMA YS_DEMO_DB.ACCOUNT_AUDIT TO SHARE USAGE_DATA_SHARE;</pre><h4>3. Grant SELECT on the Table</h4><p>Grant read-only access to the specific table containing the usage data.</p><pre>-- 3. Grant SELECT on the transient table to the Share<br>GRANT SELECT ON TABLE YS_DEMO_DB.ACCOUNT_AUDIT.ACCOUNT_USAGE_ACCESS_HISTORY TO SHARE USAGE_DATA_SHARE;<br>-- Repeat this for any other ACCOUNT_USAGE tables you want to share</pre><h4>4. Add the Consumer Account</h4><p>Specify the <strong>Account Locator</strong> of your <strong>Central Account</strong> (the account where you want to consolidate the data).</p><pre>-- 4. Add the Central Account as a consumer<br>ALTER SHARE USAGE_DATA_SHARE ADD ACCOUNTS = &lt;CENTRAL_ACCOUNT_LOCATOR&gt;;</pre><h3>OPTION 1 — Consume the Shared Data (Consumer -Central Account)</h3><p>Log into the <strong>Central Account</strong> with the <strong>ACCOUNTADMIN</strong> role (or a role with the IMPORT SHARE privilege) and execute the following steps:</p><h4>1. Create a Database from the Share</h4><p>This creates a new read-only database in your Central Account that points to the shared tables in the Source Account.</p><pre>USE ROLE ACCOUNTADMIN;<br><br>-- 1. Create a database from the share object<br>-- Use the format: &lt;SOURCE_ACCOUNT_LOCATOR&gt;.&lt;SHARE_NAME&gt;<br>CREATE DATABASE &lt;SOURCE_ACCOUNT_DB_NAME&gt; <br>FROM SHARE &lt;SOURCE_ACCOUNT_LOCATOR&gt;.USAGE_DATA_SHARE; <br>-- Example: CREATE DATABASE ACCOUNT_A_USAGE FROM SHARE AB12345.USAGE_DATA_SHARE;</pre><h4>2. Grant Access to Roles</h4><p>Grant your administrative or analysis role the privilege to query the new shared database.</p><pre>-- 2. Grant access to your analytics role (e.g., SYSADMIN)<br>GRANT IMPORTED PRIVILEGES ON DATABASE &lt;SOURCE_ACCOUNT_DB_NAME&gt; TO ROLE SYSADMIN;</pre><h4>3. Consolidate the Data</h4><p>You can now query the shared table like any other table and load the data into a master consolidation table, tagging it with the source account name.</p><pre>-- 3. Query the shared data and insert it into a central table<br>USE ROLE SYSADMIN;<br>USE DATABASE &lt;MASTER_CONSOLIDATION_DB&gt;;<br><br>INSERT INTO MASTER_CONSOLIDATION_DB.PUBLIC.ALL_ACCESS_HISTORY (<br>    SELECT *<br>    FROM &lt;SOURCE_ACCOUNT_DB_NAME&gt;.ACCOUNT_AUDIT.ACCOUNT_USAGE_ACCESS_HISTORY<br>    -- Use a MERGE or WHERE clause here to ensure you only load new records<br>    -- based on the DATE COLUMN to avoid duplicates on every run.<br>);</pre><p>You will repeat Steps 2 and 3 for every account you want to consolidate.</p><p>You can use a <strong>scheduled</strong> <strong>task</strong> or ETL process to copy the data from the new shared database into a single, master consolidation table. This process will repeat for every shared account.</p><h3>OPTION 2- Share Data via Internal Marketplace</h3><p>This option replaces the Direct Share. It uses Snowflake’s publishing feature for a self-service consumption model.</p><h4>Step 1- Source Account (Provider) Steps (Publishing the Listing)</h4><p>Ensure you are logged into the <strong>Source Account</strong> (e.g., ACCOUNT_1) with the <strong>ACCOUNTADMIN</strong> role and navigate to <strong>Snowsight</strong>.</p><h4>A. Set up the Share (via SQL)</h4><p>You still need a standard share object and grants, but you <strong>do not</strong> add consumer accounts.</p><pre>USE ROLE ACCOUNTADMIN;<br><br>-- 1. Create the Share object<br>CREATE OR REPLACE SHARE USAGE_MARKETPLACE_SHARE;<br><br>-- 2. Grant USAGE on the database and schema to the Share<br>GRANT USAGE ON DATABASE YS_DEMO_DB TO SHARE USAGE_MARKETPLACE_SHARE;<br>GRANT USAGE ON SCHEMA YS_DEMO_DB.ACCOUNT_AUDIT TO SHARE USAGE_MARKETPLACE_SHARE;<br><br>-- 3. Grant SELECT on the table to the Share<br>GRANT SELECT ON TABLE YS_DEMO_DB.ACCOUNT_AUDIT.ACCOUNT_USAGE_ACCESS_HISTORY TO SHARE USAGE_MARKETPLACE_SHARE;<br>-- Repeat for all tables...</pre><h4>B. Create the Listing (via Snowsight)</h4><ol><li>In Snowsight, navigate to <strong>Data Sha → Provider Studio</strong>.</li><li>Select <strong>Listings → + Listing</strong> → Internal Marketplace</li><li><strong>Name the Listing:</strong> Give it a clear name, e.g., ACCOUNT_1_USAGE_METRICS.</li><li><strong>Data:</strong> Select the <strong>Database → Schema → Table</strong> you want to include (e.g., YS_DEMO_DB.ACCOUNT_AUDIT.ACCOUNT_USAGE_ACCESS_HISTORY) → <strong>Save</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QFZp59zTKXCrZDRY3XWOgg.png" /></figure><p><strong>5. Navigate to Access Control:</strong> On the publishing guide checklist, select the <strong>Set up access</strong> step.</p><ul><li>Grant Access:</li><li>For <strong>“Who can access this data product?”</strong>, select <strong>Selected accounts and roles</strong>.</li><li>In the <strong>Accounts</strong> section, click <strong>Select an account</strong> (or the dropdown next to the default account) and add your <strong>Central Monitoring Account Locator</strong> (e.g., XY12345).</li><li>You can leave the associated role as <strong>All roles</strong> or restrict it to the ACCOUNTADMIN role in your Central Account.</li></ul><p>Allow Discovery:</p><ul><li>For <strong>“Who else can discover the listing and request access?”</strong>, select <strong>Not discoverable by users without access</strong>. This keeps the listing private and only visible to the Central Monitoring Account you explicitly added.</li></ul><p>6. <strong>Publish</strong>: Review all the green checkmarked sections to ensure all required fields are complete (such as ‘Support Contact’ Email).</p><ul><li>Description for example can be:<br><em>”This listing provides read-only access to consolidated Snowflake usage metadata from ACCOUNT_1.</em></li><li><em>Data is refreshed daily via a scheduled stored procedure and is intended for ingestion into the Organization Monitoring Account’s master tables.</em></li><li><em>The tables include key views from the SNOWFLAKE.ACCOUNT_USAGE schema with low-latency data and extended retention, including:</em></li><li><em>ACCOUNT_USAGE_ACCESS_HISTORY</em></li><li><em>ACCOUNT_USAGE_QUERY_HISTORY</em></li><li><em>ACCOUNT_USAGE_LOGIN_HISTORY”</em></li></ul><p><strong>7. Publish:</strong> Click the <strong>Publish</strong> button to make the listing active and available to your Central Monitoring Account on the Internal Marketplace.</p><h4>Step 2 — Central Account (Consumer) Steps (Self-Service) 🛒</h4><p>Log into the <strong>Central Account</strong> (the Organization Monitoring Account) with the <strong>ACCOUNTADMIN</strong> role and navigate to <strong>Snowsight</strong>.</p><h4>A. Find and Subscribe to the Listing</h4><ol><li>Navigate to <strong>Internal Marketplace</strong>.</li><li>Search for the Listing name (e.g., ACCOUNT_1_USAGE_METRICS).</li><li>Click on the Listing and select <strong>Get Data</strong> → Query in worksheet.</li></ol><h4>B. Configure the New Database</h4><ol><li>The new read-only database (e.g., USAGE_FROM_ACCOUNT_1) appears in your object explorer.</li><li>Run the final consolidation step exactly as before:</li></ol><pre>-- Query the shared data and insert it into a central table<br>USE ROLE SYSADMIN;<br>USE DATABASE &lt;MASTER_CONSOLIDATION_DB&gt;;<br><br>INSERT INTO MASTER_CONSOLIDATION_DB.PUBLIC.ALL_ACCESS_HISTORY (<br>    SELECT *<br>    FROM USAGE_FROM_ACCOUNT_1.ACCOUNT_AUDIT.ACCOUNT_USAGE_ACCESS_HISTORY<br>    -- Ensure you use a WHERE clause or MERGE statement to avoid duplicates<br>    -- on subsequent runs.<br>);</pre><p><strong>Result:</strong> The Internal Marketplace offers a centralized location for your Source Accounts to publish data, and for your Central Account to easily discover and subscribe to it.</p><blockquote><em>Thanks to Mark Mayo for their insights, reviews, and contributions to this work.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97ca79e3e4e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/account-usage-consolidation-97ca79e3e4e6">ACCOUNT_USAGE Consolidation</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>