### Download SnowSQL Installer Example (Azure) Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config Example of downloading the SnowSQL installer for bootstrap version 1.5 and SnowSQL version 1.5.0 from the Azure endpoint. ```bash curl -O https://sfc-repo.azure.snowflakecomputing.com/snowsql/bootstrap/1.5/darwin_x86_64/snowsql-1.5.0-darwin_x86_64.pkg ``` -------------------------------- ### Example: Download SnowSQL Installer (Azure Endpoint) Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config This is an example of downloading the SnowSQL installer from the Microsoft Azure endpoint with specific version numbers (bootstrap_version=1.5, version=1.5.0). ```bash $ curl -O https://sfc-repo.azure.snowflakecomputing.com/snowsql/bootstrap/1.5/linux_x86_64/snowsql-1.5.0-linux_x86_64.bash ``` -------------------------------- ### Example: Download SnowSQL Installer (AWS Endpoint) Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config This is an example of downloading the SnowSQL installer from the AWS endpoint with specific version numbers (bootstrap_version=1.5, version=1.5.0). ```bash $ curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.5/linux_x86_64/snowsql-1.5.0-linux_x86_64.bash ``` -------------------------------- ### Download SnowSQL Installer Example (AWS) Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config Example of downloading the SnowSQL installer for bootstrap version 1.5 and SnowSQL version 1.5.0 from the AWS endpoint. ```bash curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.5/darwin_x86_64/snowsql-1.5.0-darwin_x86_64.pkg ``` -------------------------------- ### Example Download SnowSQL Installer via Azure Endpoint Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config Example command to download SnowSQL installer from Azure endpoint with specific versions (bootstrap 1.5, version 1.5.0). ```bash curl -O https://sfc-repo.azure.snowflakecomputing.com/snowsql/bootstrap/1.5/windows_x86_64/snowsql-1.5.0-windows_x86_64.msi ``` -------------------------------- ### Example Download SnowSQL Installer via AWS Endpoint Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config Example command to download SnowSQL installer from AWS endpoint with specific versions (bootstrap 1.5, version 1.5.0). ```bash curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.5/windows_x86_64/snowsql-1.5.0-windows_x86_64.msi ``` -------------------------------- ### Setup Provider Activation Share Mount Task Source: https://docs.snowflake.com/en/user-guide/cleanrooms/provider Enables provider activation when the provider does not have the clean room UI installed. This starts a thread to asynchronously mount consumer shares. Call this once after adding consumers. ```sql CALL samooha_by_snowflake_local_db.provider.setup_provider_activation_share_mount_task(15); ``` -------------------------------- ### Create Warehouse, Database, and Use Them Source: https://docs.snowflake.com/en/user-guide/tutorials/create-your-first-iceberg-table Sets up the necessary warehouse and database for the tutorial. Ensure you have the required privileges to create these objects. ```sql CREATE WAREHOUSE iceberg_tutorial_wh WAREHOUSE_TYPE = STANDARD WAREHOUSE_SIZE = XSMALL; USE WAREHOUSE iceberg_tutorial_wh; CREATE OR REPLACE DATABASE iceberg_tutorial_db; USE DATABASE iceberg_tutorial_db; ``` -------------------------------- ### Create Database, Schema, and Table for Tutorial Source: https://docs.snowflake.com/en/user-guide/tutorials/data-quality-tutorial-start Sets up the necessary database ('dq_tutorial_db'), schema ('sch'), and a 'customers' table within the 'dq_tutorial_role' context. ```sql USE ROLE dq_tutorial_role; CREATE DATABASE IF NOT EXISTS dq_tutorial_db; CREATE SCHEMA IF NOT EXISTS sch; CREATE TABLE customers ( account_number NUMBER(38,0), first_name VARCHAR(16777216), last_name VARCHAR(16777216), email VARCHAR(16777216), phone VARCHAR(16777216), created_at TIMESTAMP_NTZ(9), street VARCHAR(16777216), city VARCHAR(16777216), state VARCHAR(16777216), country VARCHAR(16777216), zip_code NUMBER(38,0) ); ``` -------------------------------- ### Install Sample Table Source: https://docs.snowflake.com/en/user-guide/cleanrooms/installed-artifacts Execute this SQL command with ACCOUNTADMIN role to install the CUSTOMERS_2 sample table if it's not present. ```sql USE ROLE ACCOUNTADMIN; EXECUTE IMMEDIATE FROM @SAMOOHA_BY_SNOWFLAKE.APP_SCHEMA.MOUNT_CODE_STAGE/dcr_loader.sql; ``` -------------------------------- ### Create Sample Tables and Views Source: https://docs.snowflake.com/en/user-guide/object-dependencies SQL commands to create sample tables and views for demonstrating object dependencies. ```sql CREATE TABLE sales_na (product string); CREATE OR REPLACE VIEW north_america_sales AS SELECT * FROM sales_na; CREATE TABLE sales_uk (product string); CREATE VIEW global_sales AS SELECT * FROM sales_uk UNION ALL SELECT * FROM north_america_sales; ``` -------------------------------- ### Setup and Data Preparation Source: https://docs.snowflake.com/en/user-guide/cleanrooms/demo-flows/basic-multiparty-collab Initializes the environment by setting warehouse and role, and creates sample data for the collaboration. Ensure secondary roles are not active for join operations. ```sql USE WAREHOUSE APP_WH; USE ROLE SAMOOHA_APP_ROLE; -- Secondary roles can't be active when calling join or link_data_offering. USE SECONDARY ROLES NONE; -- Create sample data. CREATE DATABASE IF NOT EXISTS BOB_DB; CREATE SCHEMA IF NOT EXISTS BOB_DB.BOB_SCH; CREATE OR REPLACE TABLE BOB_DB.BOB_SCH.BOB_DATA AS SELECT * FROM samooha_sample_database.demo.customers_2 LIMIT 100; ``` -------------------------------- ### Load History Scan GET URL Example Source: https://docs.snowflake.com/en/user-guide/data-load-snowpipe-rest-apis Example of the GET URL structure for the `loadHistoryScan` endpoint, including account, pipe name, and time range parameters. ```text https://{account}.snowflakecomputing.com/v1/data/pipes/{pipeName}/loadHistoryScan?startTimeInclusive=&endTimeExclusive=&requestId= ``` -------------------------------- ### Create Database from Share (Example) Source: https://docs.snowflake.com/en/user-guide/data-share-consumers Example of creating a database named 'snow_sales' from the 'sales_s' share provided by 'xy12345'. This requires the role 'r1' to have the necessary privileges. ```sql use role r1; create database snow_sales from share xy12345.sales_s; ``` -------------------------------- ### Install Dependencies and Start Development Server Source: https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code-desktop/building-apps Run these commands after scaffolding an app to install project dependencies and start the local development server. The app will be accessible at http://localhost:3000 with hot reload enabled. ```bash npm install npm run dev ``` -------------------------------- ### Managed Plugin Registry Example Source: https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code-plugins The registry.json file tracks managed plugins installed via 'cortex plugin install'. It stores installation details, update timestamps, and error information. ```json { "data-engineering": { "source": "github:my-org/cortex-code-data-eng#main", "installedAt": "2026-04-24T10:15:00Z", "updatedAt": "2026-04-24T10:15:00Z", "active": true, "lastUpdateError": null } } ``` -------------------------------- ### Set Up Environment for Hybrid Tables Source: https://docs.snowflake.com/en/user-guide/tutorials/getting-started-with-hybrid-tables-tutorial Sets the role, warehouse, database, and schema for the hybrid tables quickstart. Ensure these are correctly configured before running other commands. ```sql USE ROLE hybrid_quickstart_role; USE WAREHOUSE hybrid_quickstart_wh; USE DATABASE hybrid_quickstart_db; USE SCHEMA data; ``` -------------------------------- ### Provider Setup: Create Sample Data and Policies Source: https://docs.snowflake.com/en/user-guide/cleanrooms/free-form-sql Sets up a sample customer dataset, aggregation, join, and masking policies for a data clean room provider. Ensures correct roles and warehouses are used. ```sql -- ============================================================================ -- Free-form SQL Collaboration Demo: Data Provider -- ============================================================================ -- This example demonstrates a Snowflake Data Clean Rooms collaboration using -- freeform SQL policies. The data provider creates a sample dataset with -- Snowflake aggregation, join, and masking policies, registers a data offering -- that permits freeform SQL queries, creates a template, and initializes a -- collaboration with one other collaborator (data_consumer). -- -- For more information, see: -- docs.snowflake.com/user-guide/cleanrooms/free-form-sql.rst -- docs.snowflake.com/user-guide/cleanrooms/spec-reference -- ============================================================================ -- ============================================================================ -- SETUP: Create sample database, schema, table, and policies. -- ============================================================================ USE ROLE SAMOOHA_APP_ROLE; USE WAREHOUSE APP_WH; -- You can't use secondary roles with most collaboration procedures. USE SECONDARY ROLES NONE; CREATE DATABASE IF NOT EXISTS PROVIDER_DB; CREATE SCHEMA IF NOT EXISTS PROVIDER_DB.DATA_SCH; -- Create a table with 300 rows from the sample CUSTOMERS table. CREATE OR REPLACE TABLE PROVIDER_DB.DATA_SCH.CUSTOMERS AS SELECT HASHED_EMAIL, STATUS, AGE_BAND, REGION_CODE, DAYS_ACTIVE, INCOME_BRACKET FROM SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS LIMIT 300; -- Create an aggregation policy that requires a minimum group size of 5. CREATE OR REPLACE AGGREGATION POLICY PROVIDER_DB.DATA_SCH.MIN_GROUP_SIZE_POLICY AS () RETURNS AGGREGATION_CONSTRAINT -> AGGREGATION_CONSTRAINT(MIN_GROUP_SIZE => 5); -- Create an inactive join policy. You will modify this later. CREATE OR REPLACE JOIN POLICY PROVIDER_DB.DATA_SCH.EMAIL_JOIN_POLICY AS () RETURNS JOIN_CONSTRAINT -> JOIN_CONSTRAINT(JOIN_REQUIRED => FALSE); -- Create a masking policy that replaces the original value with a fixed string. CREATE OR REPLACE MASKING POLICY PROVIDER_DB.DATA_SCH.MASK_INCOME_POLICY AS (val STRING) RETURNS STRING -> '***MASKED***'; -- ============================================================================ -- Register a data offering with freeform SQL policies. -- ============================================================================ -- The data offering enables freeform SQL queries (template_and_freeform_sql) -- and attaches three Snowflake policies to protect data in freeform queries: -- * Aggregation policy on hashed_email: enforces a minimum group size of 5. -- * Join policy on hashed_email: requires joins to include this column. -- * Masking policy on income_bracket: masks the column value in query results. CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.REGISTRY.REGISTER_DATA_OFFERING( $$ api_version: 2.0.0 spec_type: data_offering version: V1 name: provider_customers description: Customer dataset with freeform SQL policies. datasets: - alias: customers data_object_fqn: PROVIDER_DB.DATA_SCH.CUSTOMERS object_class: custom allowed_analyses: template_and_freeform_sql schema_and_template_policies: HASHED_EMAIL: category: join_standard column_type: hashed_email_b64_encoded STATUS: category: passthrough AGE_BAND: category: passthrough DAYS_ACTIVE: category: passthrough INCOME_BRACKET: category: passthrough freeform_sql_policies: aggregation_policy: name: PROVIDER_DB.DATA_SCH.MIN_GROUP_SIZE_POLICY entity_keys: - HASHED_EMAIL_B64_ENCODED join_policy: name: PROVIDER_DB.DATA_SCH.EMAIL_JOIN_POLICY columns: ``` -------------------------------- ### Get users whose userName starts with a prefix Source: https://docs.snowflake.com/en/user-guide/scim-user-api-reference Search for users with a Snowflake LOGIN_NAME that starts with the specified prefix. The search is case-insensitive. ```http GET /scim/v2/Users?filter=userName sw "al" ``` -------------------------------- ### Create Database, Warehouse, and Set Context Source: https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/tutorials/cortex-search-tutorial-3-chat-advanced Execute these SQL statements to set up the necessary database and warehouse for the tutorial. The warehouse is created to be initially suspended. ```sql CREATE DATABASE IF NOT EXISTS cortex_search_tutorial_db; CREATE OR REPLACE WAREHOUSE cortex_search_tutorial_wh WITH WAREHOUSE_SIZE='X-SMALL' AUTO_SUSPEND = 120 AUTO_RESUME = TRUE INITIALLY_SUSPENDED=TRUE; USE WAREHOUSE cortex_search_tutorial_wh; ``` -------------------------------- ### Request Cross-Cloud Clean Room Installation Source: https://docs.snowflake.com/en/user-guide/cleanrooms/consumer Initiates the setup for installing a clean room from another cloud region. Call this procedure periodically until the status is FULFILLED, then call `consumer.install_cleanroom`. Installation can take up to 10 minutes. ```sql CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.consumer.request_laf_cleanroom( $cleanroom_name,$provider_locator); ``` -------------------------------- ### Example Output of Get Notification Integrations Source: https://docs.snowflake.com/en/user-guide/budgets/notifications This is an example of the tabular output you can expect when calling GET_NOTIFICATION_INTEGRATIONS, showing integration names, last notification times, and addition dates. ```text +----------------------------------+------------------------+------------+ | INTEGRATION_NAME | LAST_NOTIFICATION_TIME | ADDED_DATE | +----------------------------------+------------------------+------------+ | budgets_notification_integration | -1 | 2024-09-23 | +----------------------------------+------------------------+------------+ ``` -------------------------------- ### Full Example: Matching Pattern at Partition Start Source: https://docs.snowflake.com/en/user-guide/match-recognize-introduction Demonstrates matching a pattern that must begin at the start of a partition using '^'. It selects rows where the stock price is greater than 60.00, but only considers the first such row if multiple exist at the start. ```sql SELECT * FROM stock_price_history MATCH_RECOGNIZE ( PARTITION BY company ORDER BY price_date MEASURES MATCH_NUMBER() AS "Match #", MATCH_SEQUENCE_NUMBER() AS "Match Sequence #" ALL ROWS PER MATCH PATTERN (^ GT60) DEFINE GT60 AS price > 60.00 ) ORDER BY "Match #", "Match Sequence #"; ``` -------------------------------- ### Clone GitHub Repository Source: https://docs.snowflake.com/en/user-guide/snowflake-cortex/snowflake-cowork/getting-started Clone the GitHub repository for getting started with Snowflake Cortex to your local machine. ```bash git clone https://github.com/Snowflake-Labs/sfguide-getting-started-with-snowflake-intelligence.git ``` -------------------------------- ### Install Clean Room and Query Free-Form Views Source: https://docs.snowflake.com/en/user-guide/cleanrooms/web-app-sql-template Consumer steps to install a clean room, list available free-form SQL views, and run standard SQL queries against them. Replace placeholders like '' and '' with actual values. ```sql -- Install the clean room. USE ROLE SAMOOHA_APP_ROLE; SET cleanroom_name = 'freeform queries'; CALL samooha_by_snowflake_local_db.consumer.install_cleanroom($cleanroom_name, ''); -- List free form views available in the clean room. CALL samooha_by_snowflake_local_db.consumer.GET_PROVIDER_FREEFORM_SQL_VIEWS($cleanroom_name); -- Run queries on the views SELECT * FROM ; SELECT * FROM ; SELECT COUNT(hashed_email), age_band FROM group by age_band; ``` -------------------------------- ### Run Specific SnowSQL Version Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config Start SnowSQL using a specific installed version by providing the version number with the `-v` option. ```bash $ snowsql -v 1.3.0 ``` -------------------------------- ### Create and Populate Tables and Stream Source: https://docs.snowflake.com/en/user-guide/streams-examples Sets up a source table 'members', a stream 'member_check' to track its changes, and a helper table 'signup'. It then populates the 'members' table. ```SQL CREATE OR REPLACE TABLE members ( id number(8) NOT NULL, name varchar(255) default NULL, fee number(3) NULL ); CREATE OR REPLACE STREAM member_check ON TABLE members; CREATE OR REPLACE TABLE signup ( id number(8), dt DATE ); INSERT INTO members (id,name,fee) VALUES (1,'Joe',0), (2,'Jane',0), (3,'George',0), (4,'Betty',0), (5,'Sally',0); INSERT INTO signup VALUES (1,'2018-01-01'), (2,'2018-02-15'), (3,'2018-05-01'), (4,'2018-07-16'), (5,'2018-08-21'); ``` -------------------------------- ### Cumulative Window Frame Example Source: https://docs.snowflake.com/en/user-guide/functions-window-using This frame starts at a fixed point and moves row by row through the partition, suitable for cumulative calculations. ```sql OVER(PARTITION BY col1 ORDER BY col2 ROWS UNBOUNDED PRECEDING) ``` -------------------------------- ### Consumer: Install Clean Room (Initial Call) Source: https://docs.snowflake.com/en/user-guide/cleanrooms/enabling-laf This SQL script shows the consumer's initial attempt to install a clean room. The first call may fail with a replication error, indicating the cross-cloud/region installation process has begun. Continue calling this procedure until it succeeds. ```sql USE WAREHOUSE APP_WH; USE ROLE SAMOOHA_APP_ROLE; SET cleanroom_name = 'LAF example'; SET provider_locator = ''; -- Initial call starts the process and returns a cross-cloud/region replication failure. -- Continue to call this procedure until it returns a success message. CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.consumer.install_cleanroom( $cleanroom_name, $provider_locator); -- Continue with standard clean room configuration and use. -- The consumer can run analyses, but client custom templates, provider run, and provider analysis -- aren't supported until the provider takes the action shown in the next step. ... ``` -------------------------------- ### Create Azure Storage Integration (Example) Source: https://docs.snowflake.com/en/user-guide/data-load-snowpipe-auto-azure Example of creating an Azure storage integration with specific allowed and blocked locations for granular control. ```sql CREATE STORAGE INTEGRATION azure_int TYPE = EXTERNAL_STAGE STORAGE_PROVIDER = 'AZURE' ENABLED = TRUE AZURE_TENANT_ID = 'a123b4c5-1234-123a-a12b-1a23b45678c9' STORAGE_ALLOWED_LOCATIONS = ('azure://myaccount.blob.core.windows.net/mycontainer1/mypath1/', 'azure://myaccount.blob.core.windows.net/mycontainer2/mypath2/') STORAGE_BLOCKED_LOCATIONS = ('azure://myaccount.blob.core.windows.net/mycontainer1/mypath1/sensitivedata/', 'azure://myaccount.blob.core.windows.net/mycontainer2/mypath2/sensitivedata/') ``` -------------------------------- ### Background Subagent Execution Example Source: https://docs.snowflake.com/en/user-guide/cortex-code/extensibility Run a subagent in the background while continuing to work. The agent starts immediately and returns an ID for tracking. ```text > Run a background agent to refactor all the test files ``` -------------------------------- ### SQL for Snowflake Setup Source: https://docs.snowflake.com/en/user-guide/snowpipe-streaming/snowpipe-streaming-high-performance-getting-started SQL commands to create a user, role, database, schema, table, and configure key-pair authentication. Ensure you have the necessary privileges and replace placeholders with your desired names. ```sql -- 1. Create a dedicated role and user (Run with a highly-privileged role) CREATE OR REPLACE USER MY_USER; CREATE ROLE IF NOT EXISTS MY_ROLE; GRANT ROLE MY_ROLE TO USER MY_USER; -- 2. Set the public key for key-pair authentication -- NOTE: Replace 'YOUR_FORMATTED_PUBLIC_KEY' with the output of the PUBK variable from the key generation step. ALTER USER MY_USER SET RSA_PUBLIC_KEY='YOUR_FORMATTED_PUBLIC_KEY'; -- 3. Set the default role (Recommended) ALTER USER MY_USER SET DEFAULT_ROLE=MY_ROLE; -- 4. Switch to the new role and create objects USE ROLE MY_ROLE; -- NOTE: You may also need to run USE WAREHOUSE YOUR_WH; here if a default warehouse isn't set. -- Create database and schema CREATE OR REPLACE DATABASE MY_DATABASE; CREATE OR REPLACE SCHEMA MY_SCHEMA; -- Create a target table CREATE OR REPLACE TABLE MY_TABLE ( data VARIANT, c1 NUMBER, c2 STRING ); -- 5. Configure authentication policy (Optional, but recommended for explicit control) CREATE OR REPLACE AUTHENTICATION POLICY testing_auth_policy AUTHENTICATION_METHODS = ('KEYPAIR') CLIENT_TYPES = ('DRIVERS'); -- Apply authentication policy (if created) ALTER USER MY_USER SET AUTHENTICATION POLICY testing_auth_policy; ``` -------------------------------- ### request_laf_cleanroom Source: https://docs.snowflake.com/en/user-guide/cleanrooms/consumer Initiates the setup for installing a clean room from another cloud region. This must be called before `consumer.install_cleanroom`. The status should be monitored until it is FULFILLED. ```APIDOC ## request_laf_cleanroom ### Description Sets up prerequisites for installing a clean room created on another cloud region. Calling `consumer.install_cleanroom` before calling this procedure fails. This procedure returns the current status each time you call. Call periodically until the status is FULFILLED, then call `consumer.install_cleanroom`. It can take up to 10 minutes until the status is FULFILLED. ### Method CALL ### Endpoint samooha_by_snowflake_local_db.consumer.request_laf_cleanroom ### Parameters #### Path Parameters - **cleanroom_name** (String) - Required - The name of the cross-region clean room that will be installed. - **provider_locator** (String) - Required - Account locator of the provider that created this clean room. ### Returns #### Success Response - (String) Status message of the request. Continue calling until status is FULFILLED. ### Request Example ```sql CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.consumer.request_laf_cleanroom($cleanroom_name,$provider_locator); ``` ``` -------------------------------- ### Link Datasets and View Consumer Datasets Source: https://docs.snowflake.com/en/user-guide/cleanrooms/tutorials/cleanroom-api-tutorial-basic Register and link your data into the clean room. This example uses a pre-registered sample table. It also shows how to view the datasets linked by the consumer. ```sql USE ROLE SAMOOHA_APP_ROLE; CALL samooha_by_snowflake_local_db.consumer.link_datasets( $cleanroom_name, ['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS_2']); CALL samooha_by_snowflake_local_db.consumer.view_consumer_datasets($cleanroom_name); ``` -------------------------------- ### Trust Center Extension Manifest File Source: https://docs.snowflake.com/en/user-guide/trust-center/trust-center-extensions Example of a manifest.yml file for a Trust Center extension, specifying the setup script, readme, and required privileges. ```yaml manifest_version: 1 artifacts: setup_script: setup_script.sql readme: README.md privileges: - IMPORTED PRIVILEGES ON SNOWFLAKE DB: description: "Required access to SNOWFLAKE.ACCOUNT_USAGE views to scan for vulnerabilities" ``` -------------------------------- ### Create Table and Insert Data Source: https://docs.snowflake.com/en/user-guide/querying-arrays-for-distinct-counts Creates a sample table named 'array_unique_agg_test' with an integer column 'a' and inserts sample data. This setup is required for the subsequent examples. ```sql CREATE OR REPLACE TABLE array_unique_agg_test (a INTEGER); INSERT INTO array_unique_agg_test VALUES (5), (2), (1), (2), (1); ``` -------------------------------- ### Provider: Initialize, Configure, and Publish Clean Room Source: https://docs.snowflake.com/en/user-guide/cleanrooms/enabling-laf This SQL script demonstrates the provider's actions to set up a clean room, add consumers, and publish it for installation. Ensure you replace placeholders like '' and ''. ```sql USE WAREHOUSE APP_WH; USE ROLE SAMOOHA_APP_ROLE; SET cleanroom_name = 'LAF example'; SET consumer_locator = ''; SET consumer_account_name = ''; CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.provider.cleanroom_init($cleanroom_name); CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.provider.set_default_release_directive( $cleanroom_name, 'V1_0', '0'); CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.provider.add_consumers( $cleanroom_name, $consumer_locator, $consumer_account_name); CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.provider.create_or_update_cleanroom_listing($cleanroom_name); ``` -------------------------------- ### Authenticate Databricks CLI Source: https://docs.snowflake.com/en/user-guide/cortex-code/data-platforms Guides the user through installing the Databricks CLI and authenticating to their workspace using OAuth or a personal access token. This is a prompt for Cortex Code. ```text Help me install the Databricks CLI and authenticate to my workspace ``` -------------------------------- ### Download Standard Offer Manifest Reference Source: https://docs.snowflake.com/en/user-guide/collaboration/listings/pricing-plans-offers/providers-create-manage-offers Use this SQL command to create a live version of your listing and download the offer manifest reference for a standard offer. ```sql ALTER LISTING my_listing ADD LIVE VERSION FROM LAST; GET snow://listing/my_listing/versions/live/offers/STANDARD_OFFER.yml file:///Users/my_username/ ``` -------------------------------- ### setup_provider_activation_share_mount_task Source: https://docs.snowflake.com/en/user-guide/cleanrooms/provider Enables provider activation when the provider does not have the clean room UI installed. This procedure starts a thread to asynchronously mount consumer shares needed for provider activation. ```APIDOC ## setup_provider_activation_share_mount_task ### Description Enables provider activation when the provider does not have the clean room UI installed on their account. This starts a thread to asynchronously mount consumer shares needed for provider activation. It is called only when implementing provider activation and the provider does not have the clean room UI installed. ### Arguments - `frequency_minutes` (Integer) - How often to recheck for new consumers in this clean room, in order to mount shares for them as well. A recommended value is 15. ### Returns *(String)* A success message. ### Example ```sql CALL samooha_by_snowflake_local_db.provider.setup_provider_activation_share_mount_task(15); ``` ``` -------------------------------- ### Query CSV Data with ASCII Function Source: https://docs.snowflake.com/en/user-guide/querying-stage Demonstrates calling SQL functions on columns queried from staged CSV data. Assumes prior setup from Example 1. ```sql SELECT ascii(t.$1), ascii(t.$2) FROM @mystage1 (file_format => myformat) t; +-------------+-------------+ | ASCII(T.$1) | ASCII(T.$2) | |-------------+-------------| | 97 | 98 | | 99 | 100 | | 101 | 102 | | 103 | 104 | +-------------+-------------+ ``` -------------------------------- ### Create Database, Warehouse, and Set Context Source: https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/tutorials/cortex-search-tutorial-2-chat Sets up the necessary database, an auto-suspend/resume warehouse, and uses the warehouse for subsequent operations. ```sql CREATE DATABASE IF NOT EXISTS cortex_search_tutorial_db; CREATE OR REPLACE WAREHOUSE cortex_search_tutorial_wh WITH WAREHOUSE_SIZE='X-SMALL' AUTO_SUSPEND = 120 AUTO_RESUME = TRUE INITIALLY_SUSPENDED=TRUE; USE WAREHOUSE cortex_search_tutorial_wh; ``` -------------------------------- ### Create View Example Source: https://docs.snowflake.com/en/user-guide/access-history Example of creating a view, illustrating how source and projected columns are recorded in ACCESS_HISTORY. ```sql CREATE OR REPLACE VIEW v1 (vc1, vc2) AS SELECT c1 as vc1, c2 as vc2 FROM t WHERE t.c3 > 0 ; ``` -------------------------------- ### Get Notification Integrations for Account Budget Source: https://docs.snowflake.com/en/user-guide/budgets/notifications Retrieve a list of all notification integrations currently associated with the account-level budget. This helps in verifying the setup and understanding which integrations are active. ```sql CALL SNOWFLAKE.LOCAL.ACCOUNT_ROOT_BUDGET!GET_NOTIFICATION_INTEGRATIONS(); ``` -------------------------------- ### Get Notification Integration Name for Account Budget Source: https://docs.snowflake.com/en/user-guide/budgets/notifications Retrieves the name of the email notification integration currently associated with the account budget. This is used to verify the integration setup. ```sql CALL SNOWFLAKE.LOCAL.ACCOUNT_ROOT_BUDGET!GET_NOTIFICATION_INTEGRATION_NAME(); ``` -------------------------------- ### Example Output of SHOW CONNECTIONS Source: https://docs.snowflake.com/en/user-guide/client-redirect This is an example of the output you can expect when running the SHOW CONNECTIONS command. It details various attributes of each connection, including regional information, account names, and replication targets. ```text +--------------------+-------------------------------+---------------------+-------------------+-----------------+---------------+-------------------------------+-------------------------------------+-------------------------------------------+-------------------+-------------------+ | snowflake_region | created_on | account_name | name | comment | is_primary | primary | failover_allowed_to_accounts | connection_url | organization_name | account_locator | |--------------------+-------------------------------+---------------------+-------------------+-----------------+---------------+-------------------------------+-------------------------------------+-------------------------------------------+-------------------+-------------------| | AWS_US_WEST_2 | 2023-07-05 08:57:11.143 -0700 | MYORG.MYACCOUNT1 | MYCONNECTION | NULL | true | MYORG.MYACCOUNT1.MYCONNECTION | MYORG.MYACCOUNT2, MYORG.MYACCOUNT3 | myorg-myconnection.snowflakecomputing.com | MYORG | MYACCOUNTLOCATOR1 | | AWS_US_EAST_1 | 2023-07-08 09:15:11.143 -0700 | MYORG.MYACCOUNT2 | MYCONNECTION | NULL | false | MYORG.MYACCOUNT1.MYCONNECTION | MYORG.MYACCOUNT2, MYORG.MYACCOUNT3 | myorg-myconnection.snowflakecomputing.com | MYORG | MYACCOUNTLOCATOR1 | |--------------------+-------------------------------+---------------------+-------------------+-----------------+---------------+-------------------------------+-------------------------------------+-------------------------------------------+-------------------+-------------------+ ``` -------------------------------- ### Example output of SHOW SHARES Source: https://docs.snowflake.com/en/user-guide/data-sharing-provider This example demonstrates the output format for the SHOW SHARES command, showing share details, owner, and accounts it's shared with. ```text +-------------------------------+----------+----------------------+---------------+-----------------------+------------------+--------------+----------------------------------------+---------------------+ | created_on | kind | owner_account | name | database_name | to | owner | comment | listing_global_name | |-------------------------------+----------+----------------------+---------------+-----------------------+------------------+--------------+----------------------------------------+---------------------| | 2017-06-15 17:02:29.625 -0700 | OUTBOUND | SNOW.PRVDR1 | SALES_S | SALES_DB | XY12345, YZ23456 | ACCOUNTADMIN | | | | 2017-06-15 17:02:29.625 -0700 | OUTBOUND | SNOW.PRVDR1 | SALES_S2 | SALES_DB | XY12345, YZ23456 | ACCOUNTADMIN | | | +-------------------------------+----------+----------------------+---------------+-----------------------+------------------+--------------+----------------------------------------+---------------------+ ``` -------------------------------- ### dbt Deps Command Output and Package Lock File Source: https://docs.snowflake.com/en/user-guide/tutorials/dbt-projects-on-snowflake-getting-started-tutorial Example stdout messages from the dbt deps command, indicating successful dependency installation and the creation of the package-lock.yml file. ```text 14:47:19 Running with dbt=1.8.9 14:47:19 Updating lock file in file path: /tmp/dbt/package-lock.yml 14:47:19 Installing dbt-labs/dbt_utils 14:47:19 Installed from version 1.3.0 14:47:19 Up to date! Uploading /tmp/dbt/package-lock.yml to snow://workspace/USER$ADMIN.PUBLIC."tasty_bytes_dbt"/versions/live/dbt//package-lock.yml ``` -------------------------------- ### Create Database and Warehouse Source: https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/tutorials/cortex-search-tutorial-1-search Execute these SQL statements to set up the necessary database and virtual warehouse for the tutorial. The warehouse is configured to auto-resume when needed. ```sql CREATE DATABASE IF NOT EXISTS cortex_search_tutorial_db; CREATE OR REPLACE WAREHOUSE cortex_search_tutorial_wh WITH WAREHOUSE_SIZE='X-SMALL' AUTO_SUSPEND = 120 AUTO_RESUME = TRUE INITIALLY_SUSPENDED=TRUE; ``` -------------------------------- ### Python Embed Request Example Source: https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-rest-api/embed-api Use this Python code to send an embed request to a specified model and process the response. Ensure you have the Snowflake API library installed and are authenticated. ```python from snowflake.core import Root from snowflake.snowpark.context import get_active_session def embed_service(): # Initialize Snowflake session and root session = get_active_session() root = Root(session) # Send embed_request request and process response response = root.cortex_embed_service.embed("e5-base-v2", ['foo', 'bar']) print(response) if __name__ == "__main__": embed_service() ``` -------------------------------- ### Create Sample Data and Register Data Offering Source: https://docs.snowflake.com/en/user-guide/cleanrooms/tutorials/collaboration-basic-api-tutorial This snippet demonstrates how to create a sample database, schema, and table, and then register this data as a data offering. It specifies the API version, data offering name, datasets, and policies for data columns. ```yaml -- Create sample data. CREATE DATABASE IF NOT EXISTS BOB_DB; CREATE SCHEMA IF NOT EXISTS BOB_DB.BOB_SCH; CREATE OR REPLACE TABLE BOB_DB.BOB_SCH.BOB_DATA AS SELECT * FROM SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS_2 LIMIT 100; -- Register Bob's data offering. CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.REGISTRY.REGISTER_DATA_OFFERING( $$ api_version: 2.0.0 spec_type: data_offering version: v1 name: bob_customer_data datasets: - alias: my_customer_list data_object_fqn: BOB_DB.BOB_SCH.BOB_DATA object_class: custom allowed_analyses: template_only schema_and_template_policies: hashed_email: category: join_standard column_type: hashed_email_b64_encoded status: category: passthrough $$ ); SET bob_data_offering_id = ''; ``` -------------------------------- ### Review Loop Example (TypeScript) Source: https://docs.snowflake.com/en/user-guide/cortex-code-agent-sdk/user-input Demonstrates a simple review loop in TypeScript where a plan is rejected once with specific feedback before being approved. This is useful for enforcing plan quality and guiding the agent. ```typescript let rejectedOnce = false; const session = await createCortexCodeSession({ cwd: process.cwd(), permissionMode: "plan", canUseTool: async (toolName, input) => { if (toolName === "ExitPlanMode") { const plan = String(input.plan ?? ""); if (!rejectedOnce) { rejectedOnce = true; return { behavior: "deny", message: "Add a verification step and say which file you will edit.", }; } return { behavior: "allow", updatedInput: { message: `Approved plan: ${plan}`, }, }; } return { behavior: "allow" }; }, }); ``` -------------------------------- ### Get Snowflake PrivateLink Endpoints Info Source: https://docs.snowflake.com/en/user-guide/tables-iceberg-vended-credentials-private-connectivity Call this system function to retrieve information about Snowflake's PrivateLink endpoints, including their names and statuses. This is used in both AWS and Azure setups. ```sql SELECT SYSTEM$GET_PRIVATELINK_ENDPOINTS_INFO(); ``` -------------------------------- ### Create and Use CKE Database Source: https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-knowledge-extensions/tutorials/setup-test-cke-tutorial Grant 'create database' privilege to 'cke_owner' and then create and use the 'cke_getting_started' database. ```sql grant create database on account to role cke_owner; use role cke_owner; create database cke_getting_started; use database cke_getting_started; ``` -------------------------------- ### Query Specific XML Element Instance with XMLGET Source: https://docs.snowflake.com/en/user-guide/semistructured-data-formats Retrieve a specific instance of an XML element using the XMLGET function with an index. This example gets the third 'part' element (index 2). ```sql SELECT XMLGET(src, 'part', 2) FROM sample_xml_parts; ``` ```text +---------------------------------------+ | XMLGET(SRC, 'PART', 2) | |---------------------------------------| | Engine Coolant B6-120 XYZ company 19.00 +---------------------------------------+ ``` -------------------------------- ### Create Orafce Extension Source: https://docs.snowflake.com/en/user-guide/snowflake-postgres/postgres-extensions Installs the extension to emulate Oracle functions. ```sql CREATE EXTENSION orafce; ```