This Week in Snowflake
- Snowflake Summit 26 confirmed June 1–4, San Francisco — Openflow, Adaptive Compute, and Marketplace agents top the agenda alongside Anthropic's Daniela Amodei.
- Snowflake Intelligence + Cortex Code expanded April 21 — MCP integrations now connect to commonly used enterprise apps; external data systems including AWS Glue, Databricks, and PostgreSQL now in scope.
- Project SnowWork launched March 18 as a research preview — role-specific autonomous AI profiles for Finance, Sales, and Marketing business users, no SQL required.
- Snowflake Postgres reached GA Feb 24 — transactional and analytical workloads unified on a single platform via pg_lake Iceberg extensions, eliminating pipeline overhead.
- Observe acquisition closed early Feb 2026 — AI-powered observability with correlated logs, metrics, and traces now part of the Snowflake platform; root-cause resolution claimed 10× faster.
- Iceberg V3 support previewed April 8 — semi-structured data, row-level CDC, geospatial columns, and nanosecond timestamps are coming to the open table format.
AI_COMPLETE,AI_CLASSIFY,AI_FILTER,AI_AGG,AI_EMBEDare production-ready in Cortex AISQL — call them directly from SELECT statements without leaving Snowflake.- Snowflake Postgres powered by
pg_lakeextensions — query, manage, and write Apache Iceberg tables using standard Postgres SQL; no ETL required between OLTP and analytics layers. - Native Apps Inter-App Communication (IAC) reached GA April 28 — apps can now invoke functions and procedures across app boundaries within the same consumer account.
- Snowflake Storage for Apache Iceberg tables on AWS and Azure entered preview April 14 — Snowflake-managed infrastructure with full Iceberg interoperability, no external volume required.
- Iceberg V3 spec adds
VARIANT-equivalent semi-structured columns, row-level change data capture, geospatial types, and nanosecond-precision timestamps. - AI Credits repriced to flat $2.00 (Global) / $2.20 (Regional) per credit effective April 1, 2026 — fully decoupled from Snowflake edition.
- Cortex Code now supports cross-platform data engineering against AWS Glue, Databricks, and PostgreSQL — agentic SQL generation across heterogeneous stacks.
Platform Updates & Releases
Snowflake Makes AI Real for Businesses at Snowflake Summit 26
Summit 26 will feature announcements across four major product areas: Snowflake Openflow (a new data integration layer), Adaptive Compute (automated resource management), agentic products on Snowflake Marketplace, and expansions to Cortex AISQL and Snowflake Intelligence. The 500+ breakout session program includes 39 hands-on labs and 200+ on-site partners. The event marks Snowflake's formal pivot from "AI experimentation" positioning to "AI real for business" — a signal that the product surface has matured enough for production enterprise deployment.
Snowflake Postgres Reaches General Availability
Powered by pg_lake — a set of PostgreSQL extensions that allow Postgres to work within an open lakehouse grounded in Apache Iceberg — Snowflake Postgres enables enterprises to query, manage, and write Iceberg tables using standard SQL from within a familiar Postgres environment. This collapses the traditional boundary between OLTP and OLAP systems: teams can eliminate costly data movement pipelines between transactional and analytical layers, running both workloads on a single governed, secure platform. Available on AWS and Azure; GCP availability to follow.
Snowflake Native Apps: Inter-App Communication Reaches GA
IAC enables a Snowflake Native App to expose functions and procedures to other installed apps in the same consumer account, opening the door for composable app architectures built on Snowflake. The companion feature — Application Configuration — reached GA at the same time, providing a structured key-value coordination mechanism between a Native App and its consumer. Together, these features support lifecycle callbacks in the app manifest, so apps can react to configuration changes, validate inputs, or prepare state transitions programmatically. First entered preview February 13, 2026 (IAC) and February 20, 2026 (Configuration).
Snowflake Acquires Observe: AI-Powered Observability at Enterprise Scale
Observe's AI SRE leverages a unified context graph correlating logs, metrics, and traces, with claimed 10× faster incident resolution. The architectural bet is on open standards: the combined solution is built on Apache Iceberg for storage and OpenTelemetry for telemetry collection — both of which Snowflake already heavily supports. For data platform teams, this expands Snowflake's footprint into ITOps and opens a $50B+ addressable market in IT operations management. High-fidelity telemetry retention becomes economically viable at Snowflake's storage cost point, removing the traditional trade-off between data volume and observability budget.
Cortex AI & ML
Snowflake Expands Intelligence and Cortex Code for the Agentic Enterprise
Snowflake Intelligence now integrates with commonly used enterprise applications via the Model Context Protocol (MCP), learns from user behavior to personalize and automate recurring tasks, and routes all outputs through governed enterprise data. Over half of all Snowflake customers are now actively using Cortex Code, which has been extended to operate across external data systems: AWS Glue, Databricks, and PostgreSQL are now supported alongside native Snowflake environments. The practical implication is that Cortex Code can now generate data engineering pipelines that span heterogeneous stacks without requiring engineers to context-switch between tools.
Snowflake Launches Project SnowWork: Autonomous AI for Business Users
Unlike traditional BI or Cortex Analyst (which translate natural language into SQL), Project SnowWork is designed to complete multi-step workflows autonomously on behalf of business users: generating reports, synthesizing data across systems, and surfacing action recommendations without requiring prompt engineering. The platform ships with pre-built business role profiles that tailor the AI's reasoning to domain-specific work patterns. The research preview status means this is not yet production-ready, but the architecture signals where Snowflake is heading: governed agentic AI layered directly on top of enterprise data, with zero SQL exposure to end users.
Powering the Era of the Agentic Enterprise: Snowflake's Vision
The post articulates a three-layer architecture: the data layer (Snowflake's governed storage and compute), the intelligence layer (Cortex AI functions, Cortex Analyst, Document AI), and the agentic layer (Snowflake Intelligence, Cortex Code, Project SnowWork). Key design principles include data never leaving Snowflake's security boundary regardless of which LLM processes it, all agent actions being auditable through Snowflake's existing access history and lineage infrastructure, and MCP as the integration protocol for connecting external enterprise systems to the agentic execution environment. The H2 2026–2027 roadmap targets multi-agent collaboration, advanced observability, and deeper vertical solutions.
Snowflake Cortex Code: Complete Guide to Features, Pricing & Implementation
The guide covers Cortex Code's core capabilities: natural-language-to-SQL generation, agentic pipeline scaffolding, cross-platform code generation (Snowpark Python, SQL, dbt), and integration patterns with Snowflake's task and DAG orchestration layer. Pricing is addressed in detail given the new April 2026 AI Credits structure ($2.00 Global / $2.20 Regional per credit), with practical guidance on estimating consumption for common Cortex Code use cases. Includes worked examples for migrating Spark workloads, building incremental pipeline stored procedures, and debugging existing SQL through the Cortex Code agent interface.
Architecture & Engineering
Snowflake Expands Open Data Strategy with Iceberg V3 Support and Governance Portability
Iceberg V3 is a significant architectural leap beyond V2: the spec adds native support for variant/semi-structured columns (eliminating the need to store JSON as string blobs), row-level change data capture (enabling efficient CDC pipelines without full partition scans), geospatial data types (opening the format to location-based analytics), and nanosecond timestamp precision (critical for financial and sensor workloads). Snowflake's governance portability plan — announced alongside the V3 preview — signals intent to allow customers to take their Snowflake governance policies with their data when sharing or migrating to other query engines, a direct response to lock-in concerns raised during competitive evaluations.
Snowflake Storage for Apache Iceberg Tables Enters Preview
Previously, creating an Iceberg table on Snowflake required configuring an external volume pointing to customer-managed cloud object storage (S3 or ADLS). Snowflake Storage for Iceberg removes this dependency: tables can now be created on Snowflake-managed infrastructure while retaining full Iceberg interoperability — meaning other engines (Spark, Trino, Databricks) can still read and write the data using the open Iceberg format. This is architecturally significant because it allows teams to start with Snowflake-managed storage for simplicity, then expose the same data to the broader open-source ecosystem without migration. Related to the broader Snowflake Postgres + pg_lake architecture announced in February.
Agentic Snowpark Data Engineering Best Practices with Cortex Code
The guide covers the emerging "agentic Snowpark" development pattern: using Cortex Code as an AI pair programmer to scaffold Snowpark Python stored procedures, generate incremental pipeline logic, write test harnesses, and iterate on performance. Key best practices include: structuring stored procedures to be idempotent so Cortex Code can safely regenerate them; using STREAMS and TASKS for event-driven pipeline triggering rather than scheduled polling; and placing Cortex Code-generated code through Snowflake's built-in linting tools before deployment. The guide also covers how to integrate Cortex Code with external IDEs via the Snowflake extension for VS Code.
Introducing the Snowflake Well-Architected Framework
Modeled after AWS's Well-Architected Framework but built specifically for Snowflake's platform capabilities, the WAF articulates best practices across five interconnected pillars: Security & Governance (RBAC hierarchy, dynamic masking, row-level policies), Operational Excellence (Tasks/DAGs, Dynamic Tables, declarative pipeline patterns), Reliability (failover, replication, time-travel), Performance (clustering, query profiling, search optimization), and FinOps (resource monitors, warehouse auto-suspend, query cost attribution). Unlike third-party frameworks, WAF controls are implemented natively through Snowflake SQL — no external tooling required. On-demand training is available through Snowflake's learning platform.
Tutorials & How-Tos
Snowflake Complete Guide 2026: Architecture, Pipelines, Cortex AI, and GenAI in Production
The guide is structured in four parts: (1) architecture deep-dive covering the three-layer separation (storage, compute, services) and how Snowflake Postgres and Iceberg fit into this model; (2) pipeline engineering covering Tasks, DAGs, Dynamic Tables, and Streams for event-driven architectures; (3) Cortex AI integration patterns including AI_COMPLETE, Cortex Search, and Cortex Analyst; and (4) GenAI in production covering prompt management, model selection, safety guardrails with Cortex Guard, and cost estimation for LLM workloads. Published April 24, 2026 — reflects the current feature landscape including the February Postgres GA and April Iceberg updates.
Snowflake Cost Optimization: 12 Proven Techniques to Cut Your Bill by 40% in 2026
Key techniques covered include: setting auto-suspend to 60 seconds or less for all warehouses (15–25% immediate cost reduction), right-sizing virtual warehouses through systematic benchmarking with Snowflake's query profiler, leveraging materialized views for frequently executed complex queries, and implementing proper clustering keys on large tables (potential 70–90% query cost reduction through partition pruning). The 2026 edition addresses the March 2026 simplified hybrid table pricing and the uniform Snowpipe credit rate of 0.0037 credits per GB. Advanced techniques include credit budgeting with Resource Monitors and attribution tagging for chargeback reporting across business units.
Snowflake Managed Iceberg Tables: Complete Guide 2026
The guide covers the two Iceberg table creation paths: using an external volume pointing to customer-managed cloud storage (the original GA approach) versus the new Snowflake-managed storage preview (April 14, 2026). Includes DDL examples for both patterns, time-travel and fail-safe configuration for Iceberg tables, performance optimization through automatic file compaction, and interoperability setup for reading Snowflake-managed Iceberg tables from Spark and Trino. The guide also addresses governance: dynamic data masking policies, row access policies, and object tagging all apply natively to Iceberg tables in Snowflake — a key differentiator versus unmanaged lakehouse storage.
Snowflake as Your Single Hub for External Data Using Apache Iceberg with Snowsight
The tutorial walks through configuring external volumes pointing to S3 and ADLS, creating Iceberg catalog integrations, and using Snowsight's visual query interface to explore and manage external Iceberg tables as if they were native Snowflake objects. Key patterns include: setting up automated metadata refreshes to keep Snowflake's awareness of the external Iceberg catalog current, applying Snowflake governance policies (masking, row access, tags) to externally managed tables, and using Dynamic Tables to create Snowflake-native materialized views over external Iceberg sources for BI performance. The tutorial is particularly relevant for teams with existing Delta Lake or Iceberg data estates who want Snowflake's governance layer without a full migration.
Use Cases & Customer Stories
Gen AI in Action: Customers' Cortex AI Stories and Outcomes
Highlighted deployments include: Terakeet using Cortex AI to identify new market opportunities for clients 98% faster than prior methods by running AI_CLASSIFY and AI_AGG across large content corpora; Siemens Energy building an AI chatbot using Cortex AI and Streamlit to surface and summarize 500,000+ pages of internal R&D documents for engineering teams; and Alberta Health Services deploying Cortex AI for clinical note summarization — recording physician visits and generating structured summaries within the Snowflake security boundary (no data leaves the platform). The common thread: all deployments run AI inference inside Snowflake, so existing governance, masking, and HIPAA/GDPR compliance policies apply automatically to LLM outputs.
Secrets of Gen AI Success: Real-World Customer Stories
The analysis identifies five patterns in successful deployments: (1) starting with a governed data foundation rather than bolting AI onto an ungoverned data estate; (2) using AI to augment existing workflows rather than replace them wholesale; (3) measuring AI outputs against baseline human performance from the first sprint; (4) keeping the AI inference layer inside the security perimeter so compliance teams aren't blocked; and (5) treating AI applications as software — full CI/CD, testing, and rollback. The article uses Sigma's experience increasing sales efficiency through AI-generated account prioritization signals as a detailed case study, showing how AI output quality improves as the underlying Snowflake data model matures.
Secrets of Spark to Snowflake Migration Success: Customer Stories
The case studies reveal a consistent migration pattern: teams replace PySpark transformations with Snowpark Python stored procedures, migrate orchestration from Airflow to Snowflake Tasks and DAGs, and convert Delta Lake storage to Snowflake-managed Iceberg tables (retaining open-format interoperability). Travelpass reported significant reduction in infrastructure management overhead and improved pipeline reliability; CTC highlighted cost reduction after eliminating Spark cluster management; Swire Coca-Cola credited the migration with enabling self-service analytics across previously siloed distribution data. The post also covers the tooling landscape for automated Spark SQL to Snowflake SQL translation, which has matured significantly in 2025–2026.
Ecosystem & Industry
Databricks vs Snowflake 2026: Which One Fits Your Stack?
The analysis maps a clear division: Snowflake wins on SQL simplicity, data sharing and collaboration, governance maturity, and the new Cortex AI SQL-native inference capabilities. Databricks leads on open-source flexibility, ML/MLOps depth (managed MLflow, Unity Catalog for models), and native Spark for large-scale unstructured data processing. The 2026 competitive dynamics are significantly affected by both platforms' AI investments: Snowflake's Cortex AISQL functions are callable from any SELECT statement, while Databricks' Genie provides natural-language-to-SQL with tighter ML workbench integration. The blurring of boundaries (Snowflake with Iceberg and Snowpark, Databricks with Delta Sharing and SQL Warehouse) means most large enterprises are running both rather than making an exclusive choice.
Intra-Company Data Sharing with the Snowflake Internal Marketplace
The Internal Marketplace enables data teams to publish certified data products (tables, views, dynamic tables, Iceberg tables) for internal consumers without data movement or custom access request workflows. Consumers discover and subscribe to data products through a governed catalog UI; producers maintain control over schema changes and access grants. Key technical patterns: using data product tags to define ownership and SLAs, configuring listing-level masking policies so downstream consumers see appropriate data without needing separate copies, and integrating the Internal Marketplace with Snowflake Lineage for end-to-end data product tracking. The guide includes templates for launching a data mesh architecture on top of the Internal Marketplace.
Snowflake Automates Resource Management with Adaptive Compute
Adaptive Compute addresses one of the most common operational pain points in Snowflake: administrators manually sizing virtual warehouses for peak load while overpaying during off-peak periods. The system uses query history patterns, concurrency measurements, and queue depth signals to automatically scale warehouse size up and down within configured bounds — without requiring MULTI-CLUSTER warehouse licenses or manual intervention. A key differentiator from standard multi-cluster scaling: Adaptive Compute adjusts the warehouse size itself (XS through 6XL) in addition to adding nodes, giving finer-grained cost control for variable-workload environments. The feature is expected to be prominently featured at Summit 26 in June.
Snowflake Agentic AI Strategy 2026: From Data Insights to Business Action
The analysis frames Snowflake's agentic strategy across three horizons: Horizon 1 (current) — Cortex AISQL functions, Cortex Analyst, Document AI, and Snowflake Intelligence for single-agent task automation; Horizon 2 (H2 2026) — multi-agent collaboration via MCP, Adaptive Compute for agentic workloads, and Marketplace-distributed agentic products; Horizon 3 (2027) — industry-specific vertical agents with deep domain knowledge pre-trained on governed enterprise data. The post specifically addresses the tension between AI autonomy and data governance, arguing that Snowflake's architecture — which routes all agent actions through the existing RBAC and audit framework — is structurally better positioned for regulated industries than platforms that bolt governance on as an afterthought.
SQL Tips of the Week
5 Tips This Week-- Summarize customer feedback themes across a product category using AI_AGG.
-- AI_AGG aggregates text from multiple rows and returns a single synthesized insight.
-- Replace YOUR_DATABASE, YOUR_SCHEMA, YOUR_TABLE, and column names as appropriate.
SELECT
product_category,
COUNT(*) AS feedback_count,
-- AI_AGG synthesizes themes across all rows in the group
AI_AGG(
feedback_text,
'Identify the top 3 recurring themes in this customer feedback.
For each theme, provide a one-sentence description and note
whether sentiment is positive, negative, or mixed.'
) AS theme_analysis,
-- AI_AGG can also be used for classification summaries
AI_AGG(
feedback_text,
'What percentage of this feedback relates to: pricing, quality,
delivery, and customer service? Return as a JSON object.'
) AS category_breakdown
FROM YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_FEEDBACK
-- Filter to recent feedback for relevance
WHERE feedback_date >= DATEADD('day', -30, CURRENT_DATE())
AND feedback_text IS NOT NULL
AND LENGTH(feedback_text) > 20 -- filter out trivial entries
GROUP BY product_category
-- Focus on categories with enough data for meaningful analysis
HAVING COUNT(*) >= 10
ORDER BY feedback_count DESC;
-- Create a Resource Monitor that alerts at 75% consumption and suspends at 100%.
-- Must be executed by an ACCOUNTADMIN or role with CREATE RESOURCE MONITOR privilege.
CREATE OR REPLACE RESOURCE MONITOR ANALYTICS_TEAM_MONTHLY
WITH
-- Set monthly credit quota (adjust to your actual allocation)
CREDIT_QUOTA = 500
-- Reset the counter on the first of each month
FREQUENCY = MONTHLY
START_TIMESTAMP = IMMEDIATELY
-- Notification-only at 75% usage — sends alert email to monitor admins
TRIGGERS
ON 75 PERCENT DO NOTIFY
-- Suspend NEW queries at 90%, but allow running queries to finish
ON 90 PERCENT DO SUSPEND
-- Immediately suspend ALL warehouses at 100% — hard stop
ON 100 PERCENT DO SUSPEND_IMMEDIATE;
-- Assign the monitor to specific warehouses (can assign to multiple)
ALTER WAREHOUSE ANALYTICS_WH SET RESOURCE_MONITOR = ANALYTICS_TEAM_MONTHLY;
ALTER WAREHOUSE REPORTING_WH SET RESOURCE_MONITOR = ANALYTICS_TEAM_MONTHLY;
-- Verify the current monitor status and remaining credit budget
SELECT
name,
credit_quota,
credits_used,
credits_used_compute,
credits_used_cloud_services,
ROUND((credits_used / NULLIF(credit_quota, 0)) * 100, 2) AS pct_consumed,
suspend_at,
suspend_immediate_at
FROM SNOWFLAKE.ACCOUNT_USAGE.RESOURCE_MONITORS
WHERE name = 'ANALYTICS_TEAM_MONTHLY';
ALTER SESSION SET QUERY_TAG = 'team:analytics') so you can attribute credit consumption to specific teams, projects, or business units in ACCOUNT_USAGE reports.
-- Create a Snowflake-managed Iceberg table (no external volume required).
-- Requires ENTERPRISE edition or higher and must be in a region where
-- Snowflake Storage for Apache Iceberg is available (AWS, Azure - Apr 2026 preview).
CREATE OR REPLACE ICEBERG TABLE YOUR_DATABASE.YOUR_SCHEMA.EVENTS (
event_id STRING NOT NULL,
event_timestamp TIMESTAMP_NTZ NOT NULL,
user_id STRING,
event_type STRING,
properties OBJECT, -- semi-structured data stored as Iceberg struct
partition_date DATE NOT NULL
)
-- Snowflake manages the underlying storage; no EXTERNAL_VOLUME needed
CATALOG = 'SNOWFLAKE'
BASE_LOCATION = 'events/' -- relative path within Snowflake managed storage
-- Partition by date for query performance and lifecycle management
PARTITION BY (DAY(event_timestamp))
-- Enable automatic file compaction to reduce small file overhead
AUTO_REFRESH = TRUE;
-- Insert data (standard DML works identically to native tables)
INSERT INTO YOUR_DATABASE.YOUR_SCHEMA.EVENTS
SELECT
UUID_STRING() AS event_id,
CURRENT_TIMESTAMP() AS event_timestamp,
user_id,
event_type,
properties,
CURRENT_DATE() AS partition_date
FROM YOUR_SOURCE_TABLE
WHERE event_date = CURRENT_DATE();
-- Query with time travel (Iceberg tables support Snowflake time travel)
SELECT COUNT(*) AS events_yesterday
FROM YOUR_DATABASE.YOUR_SCHEMA.EVENTS
AT (OFFSET => -86400) -- 24 hours ago in seconds
WHERE event_type = 'purchase';
-- Inspect Iceberg metadata — useful for validating partition pruning
SELECT *
FROM TABLE(
INFORMATION_SCHEMA.ICEBERG_TABLE_FILES(
TABLE_NAME => 'EVENTS',
TABLE_SCHEMA => 'YOUR_SCHEMA'
)
)
LIMIT 20;
SYSTEM$GET_ICEBERG_TABLE_INFORMATION(). This gives you full read/write access from external engines without maintaining a separate copy of the data.
-- Identify the most expensive queries and their partition pruning efficiency
-- from the last 7 days. Run as ACCOUNTADMIN or a role with SNOWFLAKE DB access.
WITH expensive_queries AS (
SELECT
query_id,
query_text,
warehouse_name,
warehouse_size,
-- Convert milliseconds to seconds for readability
ROUND(total_elapsed_time / 1000, 2) AS elapsed_sec,
ROUND(execution_time / 1000, 2) AS execution_sec,
credits_used_cloud_services,
-- Partition pruning metrics
partitions_scanned,
partitions_total,
ROUND(
(partitions_scanned / NULLIF(partitions_total, 0)) * 100, 1
) AS pct_partitions_scanned,
-- Bytes scanned (cost proxy)
ROUND(bytes_scanned / 1e9, 3) AS gb_scanned,
ROUND(bytes_spilled_to_local_storage / 1e9, 3) AS gb_spilled_local,
ROUND(bytes_spilled_to_remote_storage / 1e9, 3) AS gb_spilled_remote,
start_time,
user_name,
role_name,
database_name,
schema_name
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE start_time >= DATEADD('day', -7, CURRENT_TIMESTAMP())
AND execution_status = 'SUCCESS'
AND query_type IN ('SELECT', 'DML')
AND partitions_total > 0 -- only queries that touched tables
AND total_elapsed_time > 10000 -- queries taking more than 10 seconds
)
SELECT
query_id,
LEFT(query_text, 120) AS query_preview,
warehouse_name,
elapsed_sec,
gb_scanned,
pct_partitions_scanned,
partitions_scanned,
partitions_total,
-- Flag queries with poor pruning (scanning >50% of partitions on large tables)
CASE
WHEN pct_partitions_scanned > 50
AND partitions_total > 100
THEN 'Clustering candidate'
WHEN gb_spilled_local > 0 OR gb_spilled_remote > 0
THEN 'Memory pressure — resize warehouse'
ELSE 'OK'
END AS recommendation,
gb_spilled_local,
gb_spilled_remote,
start_time,
user_name
FROM expensive_queries
ORDER BY gb_scanned DESC
LIMIT 25;
pct_partitions_scanned above 50% on tables with 100+ partitions is a strong signal to add an Automatic Clustering key matching your most common WHERE clause columns. Before applying clustering, run SELECT SYSTEM$CLUSTERING_INFORMATION('YOUR_TABLE', '(col1, col2)') to get a clustering depth score — a depth below 1.2 means the table is already well-clustered and clustering will not help.
-- Multi-tenant Row Access Policy: users only see rows belonging to their tenant.
-- Uses a mapping table to drive access — change access by updating the mapping,
-- no policy modification or redeployment required.
-- STEP 1: Create the tenant-to-role mapping table
CREATE OR REPLACE TABLE YOUR_DATABASE.SECURITY.TENANT_ACCESS_MAP (
tenant_id STRING NOT NULL,
role_name STRING NOT NULL,
PRIMARY KEY (tenant_id, role_name)
);
-- Populate with your tenant-role assignments
INSERT INTO YOUR_DATABASE.SECURITY.TENANT_ACCESS_MAP VALUES
('TENANT_ACME', 'ROLE_ACME_USERS'),
('TENANT_ACME', 'ROLE_PLATFORM_ADMIN'), -- admins see all tenants
('TENANT_GLOBEX', 'ROLE_GLOBEX_USERS'),
('TENANT_GLOBEX', 'ROLE_PLATFORM_ADMIN');
-- STEP 2: Create the Row Access Policy
-- The policy function returns TRUE (show row) or FALSE (hide row)
CREATE OR REPLACE ROW ACCESS POLICY YOUR_DATABASE.SECURITY.TENANT_ROW_POLICY
AS (row_tenant_id STRING) RETURNS BOOLEAN ->
-- ACCOUNTADMIN and SYSADMIN always see all rows
CURRENT_ROLE() IN ('ACCOUNTADMIN', 'SYSADMIN')
OR
-- Check if the current role has access to this row's tenant
EXISTS (
SELECT 1
FROM YOUR_DATABASE.SECURITY.TENANT_ACCESS_MAP
WHERE tenant_id = row_tenant_id
AND role_name = CURRENT_ROLE()
);
-- STEP 3: Apply the policy to your multi-tenant table
-- The 'tenant_id' column in the table maps to 'row_tenant_id' in the policy
ALTER TABLE YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_EVENTS
ADD ROW ACCESS POLICY YOUR_DATABASE.SECURITY.TENANT_ROW_POLICY
ON (tenant_id);
-- STEP 4: Verify policy application and coverage
SELECT
policy_name,
ref_entity_name AS table_name,
ref_column_name AS policy_column,
policy_status
FROM SNOWFLAKE.ACCOUNT_USAGE.POLICY_REFERENCES
WHERE policy_kind = 'ROW_ACCESS_POLICY'
AND ref_entity_name = 'CUSTOMER_EVENTS';
-- Test: a user with ROLE_ACME_USERS should only see TENANT_ACME rows
-- (run as the target user/role to validate)
SELECT DISTINCT tenant_id FROM YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_EVENTS;
-- Expected: only 'TENANT_ACME' is returned for ROLE_ACME_USERS
role_name to minimize join overhead during row filtering at scan time.