### Artifacts Setup Script Example Source: https://docs.snowflake.com/en/developer-guide/native-apps/manifest-reference Specifies the path and filename of the setup script for app installation or upgrade. Defaults to 'setup.sql' if not provided. ```yaml setup_script: scripts/setup.sh ``` -------------------------------- ### Setup Data for Examples Source: https://docs.snowflake.com/en/migrations/sma-docs/translation-reference/spark-sql/spark-sql-dml/select/where Creates and inserts data into a 'person' table for use in subsequent examples. ```sql CREATE TABLE person (id INT, name STRING, age INT); INSERT INTO person VALUES (100, 'John', 30), (200, 'Mary', NULL), (300, 'Mike', 80), (400, 'Dan' , 50); ``` ```sql CREATE TABLE person (id INT, name STRING, age INT); INSERT INTO person VALUES (100, 'John', 30), (200, 'Mary', NULL), (300, 'Mike', 80), (400, 'Dan' , 50); ``` -------------------------------- ### Setup Data for Examples Source: https://docs.snowflake.com/en/sql-reference/constructs/group-by SQL commands to create and populate 'sales' and 'products' tables for use in GROUP BY examples. ```sql CREATE TABLE sales ( product_ID INTEGER, retail_price REAL, quantity INTEGER, city VARCHAR, state VARCHAR); INSERT INTO sales (product_id, retail_price, quantity, city, state) VALUES (1, 2.00, 1, 'SF', 'CA'), (1, 2.00, 2, 'SJ', 'CA'), (2, 5.00, 4, 'SF', 'CA'), (2, 5.00, 8, 'SJ', 'CA'), (2, 5.00, 16, 'Miami', 'FL'), (2, 5.00, 32, 'Orlando', 'FL'), (2, 5.00, 64, 'SJ', 'PR'); CREATE TABLE products ( product_ID INTEGER, wholesale_price REAL); INSERT INTO products (product_ID, wholesale_price) VALUES (1, 1.00); INSERT INTO products (product_ID, wholesale_price) VALUES (2, 2.00); ``` -------------------------------- ### Examples for SCAI Data Orchestrator Setup Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/general/user-guide/snowconvert/command-line-interface/SCAI_Command_Reference Illustrates different ways to set up the SCAI Data Orchestrator, including using default connections, specific connections, and specific warehouses. These examples show practical application of the setup command. ```bash # Set up with default connection scai data orchestrator setup --compute-pool MY_COMPUTE_POOL ``` ```bash # Set up with specific connection scai data orchestrator setup --compute-pool MY_COMPUTE_POOL --connection my-snowflake ``` ```bash # Set up with a specific warehouse scai data orchestrator setup --compute-pool MY_COMPUTE_POOL --warehouse MY_WAREHOUSE ``` -------------------------------- ### Example: Download SnowSQL Installer (Azure Endpoint, v1.5.0) Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config.html This example shows how to download the SnowSQL installer version 1.5.0 using the Microsoft Azure endpoint, with bootstrap version 1.5. ```bash $ curl -O https://sfc-repo.azure.snowflakecomputing.com/snowsql/bootstrap/1.5/linux_x86_64/snowsql-1.5.0-linux_x86_64.bash ``` -------------------------------- ### Examples for SCAI Data Orchestrator Start Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/general/user-guide/snowconvert/command-line-interface/SCAI_Command_Reference Demonstrates how to start the SCAI Data Orchestrator. Examples include resuming the cloud service with default settings, specifying a role, and running the orchestrator in local mode. ```bash # Resume the cloud orchestrator scai data orchestrator start ``` ```bash # Resume with a specific role scai data orchestrator start --role MY_ROLE ``` ```bash # Run the orchestrator locally scai data orchestrator start --local ``` -------------------------------- ### Setup for HLL Function Examples Source: https://docs.snowflake.com/en/sql-reference/functions/hll_accumulate Creates and populates a sequence and a demo table used in subsequent HLL function examples. This setup is necessary to generate sample data for cardinality estimation. ```sql CREATE OR REPLACE SEQUENCE seq92; CREATE OR REPLACE TABLE sequence_demo (c1 INTEGER DEFAULT seq92.nextval, dummy SMALLINT); INSERT INTO sequence_demo (dummy) VALUES (0); INSERT INTO sequence_demo (dummy) SELECT dummy FROM sequence_demo; INSERT INTO sequence_demo (dummy) SELECT dummy FROM sequence_demo; INSERT INTO sequence_demo (dummy) SELECT dummy FROM sequence_demo; ``` -------------------------------- ### Example: Download SnowSQL Installer (Azure) Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config.html Example command to download SnowSQL version 1.5.0 with bootstrap version 1.5 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 ``` -------------------------------- ### Setup for Message Count and Error Examples Source: https://docs.snowflake.com/en/sql-reference/functions/regexp_count Creates and populates a demo table with dates and message strings for subsequent REGEXP_COUNT examples. ```sql CREATE OR REPLACE TABLE regexp_count_demo (dt DATE, messages VARCHAR); INSERT INTO regexp_count_demo (dt, messages) VALUES ('10-AUG-2025','ER-6842,LG-230,LG-150,ER-3379,ER-6210'), ('11-AUG-2025','LG-272,LG-605,LG-683,ER-5577'), ('12-AUG-2025','ER-2207,LG-551,LG-826,ER-6842'); SELECT * FROM regexp_count_demo; ``` ```sql +------------+---------------------------------------+ | DT | MESSAGES | |------------+---------------------------------------| | 2025-08-10 | ER-6842,LG-230,LG-150,ER-3379,ER-6210 | | 2025-08-11 | LG-272,LG-605,LG-683,ER-5577 | | 2025-08-12 | ER-2207,LG-551,LG-826,ER-6842 | +------------+---------------------------------------+ ``` -------------------------------- ### Example: Download SnowSQL Installer (AWS Endpoint, v1.5.0) Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config.html This example shows how to download the SnowSQL installer version 1.5.0 using the AWS endpoint, with bootstrap version 1.5. ```bash $ curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.5/linux_x86_64/snowsql-1.5.0-linux_x86_64.bash ``` -------------------------------- ### Example: Download SnowSQL Installer (AWS) Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config.html Example command to download SnowSQL version 1.5.0 with bootstrap version 1.5 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 ``` -------------------------------- ### Redshift Setup Data for Examples Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/translation-references/redshift/redshift-expressions SQL statements to create and populate tables used in subsequent Redshift expression examples. ```sql CREATE TABLE table1 ( quantity VARCHAR(50), fruit VARCHAR(50) ); CREATE TABLE table2 ( quantity VARCHAR(50), fruit VARCHAR(50) ); CREATE TABLE table3 ( id INT, name VARCHAR(50), quantity INT, fruit VARCHAR(50), price INT ); INSERT INTO table1 (quantity, fruit) VALUES ('one', 'apple'), ('two', 'banana'), ('three', 'cherry'); INSERT INTO table2 (quantity, fruit) VALUES ('one', 'apple'), ('two', 'banana'), ('four', 'orange'); INSERT INTO table3 (id, name, quantity, fruit, price) VALUES (1, 'Alice', 1, 'apple', 100), (2, 'Bob', 5, 'banana', 200), (3, 'Charlie', 10, 'cherry', 300), (4, 'David', 15, 'orange', 400); ``` -------------------------------- ### Setup Table and Data for RLIKE Examples Source: https://docs.snowflake.com/en/sql-reference/functions/rlike Creates a table and inserts sample data to be used in subsequent RLIKE function examples. ```sql CREATE OR REPLACE TABLE rlike_ex(city VARCHAR(20)); INSERT INTO rlike_ex VALUES ('Sacramento'), ('San Francisco'), ('San Jose'), (null); ``` -------------------------------- ### Example Prompt: Install and Authenticate Databricks CLI Source: https://docs.snowflake.com/en/user-guide/cortex-code/data-platforms Use this prompt to get assistance with installing the Databricks CLI and authenticating to your workspace. ```text Help me install the Databricks CLI and authenticate to my workspace ``` -------------------------------- ### Get Job History Between Specific Dates Source: https://docs.snowflake.com/en/sql-reference/functions/get_job_history Retrieves up to 10 jobs that ran between a specified start and end time. This example shows how to get jobs from three days ago up to, but not including, yesterday. ```sql SELECT * FROM TABLE(SNOWFLAKE.SPCS.GET_JOB_HISTORY( RESULT_LIMIT => 10, CREATED_TIME_START => DATEADD('day', -3, CURRENT_TIMESTAMP()), CREATED_TIME_END => DATEADD('day', -1, CURRENT_TIMESTAMP()))); ``` -------------------------------- ### Get Month Names in a Specific Locale Source: https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/1.23.0/modin/pandas_api/modin.pandas.DatetimeIndex.month_name.html Specify a locale string to `month_name()` to get month names in a different language. Ensure the locale is installed on your system. For example, 'pt_BR.utf8' for Brazilian Portuguese. ```python >>> idx = pd.date_range(start='2018-01', freq='ME', periods=3) >>> idx DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'], dtype='datetime64[ns]', freq=None) >>> idx.month_name(locale='pt_BR.utf8') Index(['Janeiro', 'Fevereiro', 'Março'], dtype='object') ``` -------------------------------- ### Include All SDK Components Source: https://docs.snowflake.com/en/developer-guide/native-apps/connector-sdk/using/choosing_components Use this command in your `setup.sql` file to enable all basic features from the SDK, excluding Task Reactor. This is recommended for first-time users. ```sql EXECUTE IMMEDIATE FROM 'native-connectors-sdk-components/all.sql'; ``` -------------------------------- ### Setup Data for SIMILAR TO Examples Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/translation-references/redshift/redshift-conditions Creates and populates a table named 'similar_table_ex' with sample data for testing pattern-matching conditions. ```sql CREATE TABLE similar_table_ex ( column_name VARCHAR(255) ); INSERT INTO similar_table_ex (column_name) VALUES ('abc_123'), ('a_cdef'), ('bxyz'), ('abcc'), ('start_hello'), ('apple'), ('banana'), ('xyzabc'), ('abc\ncccc'), ('\nabccc'), ('abc%def'), ('abc_xyz'), ('abc_1_xyz'), ('applepie'), ('start%_abc'), ('ab%_xyz'), ('abcs_123_xyz'), ('aabc123'), ('xyzxyz'), ('123abc\nanother line\nabc123'); ``` -------------------------------- ### Get Account Anomalies in Credits Example Source: https://docs.snowflake.com/en/sql-reference/classes/anomaly-insights/methods/get_account_anomalies_in_credits Call the `GET_ACCOUNT_ANOMALIES_IN_CREDITS` method to find anomalies in credit consumption for the current account between specified start and end dates. ```sql CALL SNOWFLAKE.LOCAL.ANOMALY_INSIGHTS!GET_ACCOUNT_ANOMALIES_IN_CREDITS( '2024-01-01', '2024-03-31'); ``` -------------------------------- ### Get groups for Resampler Source: https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/1.48.0/modin/pandas_api/modin.pandas.groupby.DataFrameGroupBy.groups.html Shows how to use the `groups` property with a `Resampler` object. This example groups time-series data by month start frequency and displays the resulting groups. ```python import pandas as pd ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex( ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15'])) print(ser.resample('MS').groups) ``` -------------------------------- ### Oracle Project Setup and Local Cloud Migration Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/general/technical-documentation/data-migration-and-validation/data-migration This example demonstrates the sequence of commands to initialize an Oracle project, add Oracle connection details, set the default connection, and then initiate a local cloud migration. ```bash scai init my-oracle-project -l Oracle -c my-snowflake scai connection add-oracle --source-connection prod-oracle --auth standard \ --host db.example.com --service-name ORCL --user scai --password '***' scai connection set-default -l oracle -s prod-oracle scai code extract scai code convert scai code deploy scai data migrate start -c my-snowflake ``` -------------------------------- ### Get Configuration Files Command Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/data-validation-cli/sqlserver_commands Retrieves example configuration files for SQL Server data validation. Use this to start a new validation project or customize existing templates. ```bash snowflake-data-validation sqlserver get-configuration-files \ --templates-directory ./my-templates \ --query-templates ``` -------------------------------- ### Start Database Migration Source: https://docs.snowflake.com/en/migrations/getting-started Use this prompt within the loaded Snowflake CoCo environment to begin a database migration. The agent will guide you through the process and install necessary components on the first run. ```bash start a database migration ``` -------------------------------- ### Getting values with a slice from an index tuple to a label from a MultiIndex DataFrame Source: https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/1.48.0/modin/pandas_api/modin.pandas.DataFrame.loc.html This example shows how to retrieve a range of data using a slice from a starting index tuple to a label in a DataFrame with a MultiIndex. ```APIDOC ## Getting values with a slice from an index tuple to a label from a MultiIndex DataFrame ### Description Slice from an index tuple to a label for row selection in a DataFrame with a MultiIndex. ### Method `loc` ### Parameters - **start_index_tuple** (tuple): The starting index tuple for the slice. - **end_label** (string): The ending label for the slice. ### Request Example ```python df.loc[('cobra', 'mark i'):'viper'] ``` ### Response Example ``` max_speed shield cobra mark i 12 2 mark ii 0 4 sidewinder mark i 10 20 mark ii 1 4 viper mark ii 7 1 mark iii 16 36 ``` ``` -------------------------------- ### Create Table and Show Tables Example Source: https://docs.snowflake.com/en/sql-reference/sql/alter-table Demonstrates creating a table and then showing tables matching a pattern. This is useful for verifying table creation. ```sql CREATE OR REPLACE TABLE t1(a1 number); ``` ```sql SHOW TABLES LIKE 't1'; ``` -------------------------------- ### Create and Populate Table Source: https://docs.snowflake.com/en/sql-reference/functions/to_query Creates a sample table named 'to_query_example' and populates it with initial data using VALUES. ```sql CREATE OR REPLACE TABLE to_query_example ( deptno NUMBER(2), dname VARCHAR(14), loc VARCHAR(13)) AS SELECT column1, column2, column3 FROM VALUES (10, 'ACCOUNTING', 'NEW YORK'), (20, 'RESEARCH', 'DALLAS' ), (30, 'SALES', 'CHICAGO' ), (40, 'OPERATIONS', 'BOSTON' ); ``` -------------------------------- ### Get References for a View Source: https://docs.snowflake.com/en/sql-reference/functions/get_object_references This example demonstrates how to retrieve all object references for a view named 'y_view_f' across different databases and schemas. It includes setup for tables and views to illustrate complex dependencies. ```sql -- create a database create or replace database ex1_gor_x; use database ex1_gor_x; use schema PUBLIC; -- create a set of tables create or replace table x_tab_a (mycol int not null); create or replace table x_tab_b (mycol int not null); create or replace table x_tab_c (mycol int not null); -- create views with increasing complexity of references create or replace view x_view_d as select * from x_tab_a join x_tab_b using ( mycol ); create or replace view x_view_e as select x_tab_b.* from x_tab_b, x_tab_c where x_tab_b.mycol=x_tab_c.mycol; --create a second database create or replace database ex1_gor_y; use database ex1_gor_y; use schema PUBLIC; -- create a table in the second database create or replace table y_tab_a (mycol int not null); -- create more views with increasing levels of references create or replace view y_view_b as select * from ex1_gor_x.public.x_tab_a join y_tab_a using ( mycol ); create or replace view y_view_c as select b.* from ex1_gor_x.public.x_tab_b b, ex1_gor_x.public.x_tab_c c where b.mycol=c.mycol; create or replace view y_view_d as select * from ex1_gor_x.public.x_view_e; create or replace view y_view_e as select e.* from ex1_gor_x.public.x_view_e e, y_tab_a where e.mycol=y_tab_a.mycol; create or replace view y_view_f as select e.* from ex1_gor_x.public.x_view_e e, ex1_gor_x.public.x_tab_c c, y_tab_a where e.mycol=y_tab_a.mycol and e.mycol=c.mycol; -- retrieve the references for the last view created select * from table(get_object_references(database_name=>'ex1_gor_y', schema_name=>'public', object_name=>'y_view_f')); +---------------+-------------+-----------+--------------------------+------------------------+------------------------+------------------------+ | DATABASE_NAME | SCHEMA_NAME | VIEW_NAME | REFERENCED_DATABASE_NAME | REFERENCED_SCHEMA_NAME | REFERENCED_OBJECT_NAME | REFERENCED_OBJECT_TYPE | |---------------+-------------+-----------+--------------------------+------------------------+------------------------+------------------------| | EX1_GOR_Y | PUBLIC | Y_VIEW_F | EX1_GOR_Y | PUBLIC | Y_TAB_A | TABLE | | EX1_GOR_Y | PUBLIC | Y_VIEW_F | EX1_GOR_X | PUBLIC | X_TAB_B | TABLE | | EX1_GOR_Y | PUBLIC | Y_VIEW_F | EX1_GOR_X | PUBLIC | X_TAB_C | TABLE | | EX1_GOR_Y | PUBLIC | Y_VIEW_F | EX1_GOR_X | PUBLIC | X_VIEW_E | VIEW | +---------------+-------------+-----------+--------------------------+------------------------+------------------------+------------------------+ ``` -------------------------------- ### Getting values on a DataFrame with an index that has integer labels Source: https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/1.20.0/modin/pandas_api/snowflake.snowpark.modin.pandas.DataFrame.loc.html This example shows how to use .loc for slicing rows when the DataFrame index consists of integer labels. Note that both the start and stop of the slice are included. ```APIDOC ## Getting values on a DataFrame with an index that has integer labels Another example using integers for the index ```python >>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]], ... index=[7, 8, 9], columns=['max_speed', 'shield']) >>> df max_speed shield 7 1 2 8 4 5 9 7 8 ``` Slice with integer labels for rows. As mentioned above, note that both the start and stop of the slice are included. ```python >>> df.loc[7:9] max_speed shield 7 1 2 8 4 5 9 7 8 ``` ``` -------------------------------- ### 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, warehouse, and context for the tutorial. The warehouse is created 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; ``` -------------------------------- ### 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. ```sql CALL samooha_by_snowflake_local_db.provider.setup_provider_activation_share_mount_task(15); ``` -------------------------------- ### Setup Data for Cursor Example (Redshift/Snowflake) Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/translation-references/redshift/rs-sql-statements-create-procedure Creates and populates a table used for demonstrating cursor functionality. ```sql CREATE TABLE cursor_example ( col1 INTEGER, col2 VARCHAR(20) ); CREATE TABLE cursor_example_results ( col1 INTEGER, col2 VARCHAR(20) ); INSERT INTO cursor_example VALUES (10, 'hello'); ``` -------------------------------- ### Example: Creating and Describing a Database Source: https://docs.snowflake.com/en/sql-reference/sql/desc-database This example demonstrates how to create a database and schemas, and then use DESCRIBE DATABASE to view its contents. The output shows the created schemas within the database. ```sql CREATE DATABASE desc_demo; CREATE SCHEMA sample_schema_1; CREATE SCHEMA sample_schema_2; DESCRIBE DATABASE desc_demo; ``` -------------------------------- ### Get Refresh Progress for All Groups (Custom Time Range) Source: https://docs.snowflake.com/en/sql-reference/functions/replication_group_refresh_progress Retrieve the refresh progress for all groups within a custom time range, specified by start and end dates. This example retrieves data for the last 7 days. ```sql SELECT phase_name, start_time, end_time, progress, details FROM TABLE( INFORMATION_SCHEMA.REPLICATION_GROUP_REFRESH_PROGRESS_ALL( DATE_RANGE_START => DATEADD(D, -7, CURRENT_DATE), DATE_RANGE_END => CURRENT_DATE)); ``` -------------------------------- ### Install Dependencies and Start Development Server Source: https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code-desktop/building-apps Installs project dependencies and starts the local development server for a Snowflake App Runtime application. Hot reload is enabled. ```bash npm install npm run dev ``` -------------------------------- ### Redshift Setup Data for LIKE Examples Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/translation-references/redshift/redshift-conditions Creates and populates a table named 'like_ex' with various string values for demonstrating LIKE and ILIKE conditions. ```sql CREATE TABLE like_ex(name VARCHAR(20)); INSERT INTO like_ex VALUES ('John Dddoe'), ('Joe Doe'), ('Joe Doe '), (' Joe Doe '), (' Joe Doe '), ('John_down'), ('Joe down'), ('Elaine'), (''), (null), ('1000 times'), ('100%'); ``` -------------------------------- ### Example Usage of SETUP_EXTERNAL_INTEGRATION_WITH_REFERENCES Source: https://docs.snowflake.com/en/developer-guide/native-apps/connector-sdk/reference/setup_external_integration This example demonstrates how to call the SETUP_EXTERNAL_INTEGRATION_WITH_REFERENCES procedure with an array of method signatures. ```sql CALL PUBLIC.SETUP_EXTERNAL_INTEGRATION_WITH_REFERENCES(ARRAY_CONSTRUCT( 'PUBLIC.TEST_CONNECTION()', 'PUBLIC.FINALIZE_CONFIGURATION(VARIANT)', 'PUBLIC.TEMPLATE_WORKER(NUMBER, STRING)') ); ``` -------------------------------- ### Create an Example Task Source: https://docs.snowflake.com/en/sql-reference/sql/desc-task This example demonstrates how to create a task. The task definition is a placeholder and should be replaced with actual task logic. ```sql CREATE TASK mytask ( ... ); ``` -------------------------------- ### Register Extension Example Source: https://docs.snowflake.com/en/sql-reference/stored-procedures/register_extension Example of registering an extension named 'tc_extension' installed from a private listing. ```sql CALL SNOWFLAKE.TRUST_CENTER.REGISTER_EXTENSION( 'LISTING', 'GZ13Z1VEWNG', 'tc_extension'); ``` -------------------------------- ### Create and Populate Example Table Source: https://docs.snowflake.com/en/sql-reference/functions/like_any Creates a table named 'like_example' and inserts sample string data, including strings with spaces and underscores, and a null value. ```sql CREATE OR REPLACE TABLE like_example(name VARCHAR(20)); INSERT INTO like_example VALUES ('John Dddoe'), ('Joe Doe'), ('John_down'), ('Joe down'), ('Tom Doe'), ('Tim down'), (null); ``` -------------------------------- ### Configure iODBC Setup for Snowflake Driver (TGZ Install) Source: https://docs.snowflake.com/en/developer-guide/odbc/odbc-linux Run the iODBC setup script after installing the Snowflake ODBC driver using the TGZ file. This command should be executed from the extracted 'snowflake_odbc' directory. ```bash ./iodbc_setup.sh ``` -------------------------------- ### Setup for COUNT_IF Examples Source: https://docs.snowflake.com/en/sql-reference/functions/count_if Creates and populates a table named 'basic_example' for demonstrating COUNT_IF function usage. ```sql CREATE TABLE basic_example (i_col INTEGER, j_col INTEGER); INSERT INTO basic_example VALUES (11, 101), (11, 102), (11, NULL), (12, 101), (NULL, 101), (NULL, 102); ``` -------------------------------- ### Create Tables, View, and Stream on View Source: https://docs.snowflake.com/en/user-guide/streams-examples Sets up the necessary tables, a view with a join, and a stream on that view. This is the initial setup for tracking changes. ```sql -- Create multiple tables with matching column values. CREATE TABLE birds ( id number, common varchar(100), class varchar(100) ); CREATE TABLE sightings ( d date, loc varchar(100), b_id number, c number ); -- Create a view that queries the tables with a join. CREATE VIEW bird_sightings AS SELECT b.id AS id, b.common AS common_name, b.class AS classification, s.d AS date, s.loc AS location, s.c AS count FROM birds b INNER JOIN sightings s ON b.id = s.b_id; -- Create a stream on the view. CREATE STREAM bird_sightings_s ON VIEW bird_sightings; ``` -------------------------------- ### Silent Installation of SnowSQL Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config.html Automate the SnowSQL installation on Windows by running the MSI installer with the /q flag for a quiet, non-interactive setup. The installation directory is fixed to %ProgramFiles%\Snowflake SnowSQL. ```batch C:\Users\ msiexec /i snowsql-windows_x86_64.msi /q ``` -------------------------------- ### Retrieve Installed Application Version Source: https://docs.snowflake.com/en/sql-reference/functions/sys_context_snowflake_application This example demonstrates how to retrieve the installed version of the Snowflake Native App. ```sql SELECT SYS_CONTEXT('SNOWFLAKE$APPLICATION', 'INSTALLED_VERSION'); ``` -------------------------------- ### Create Table and Load Data Source: https://docs.snowflake.com/en/sql-reference/functions/bitand_agg Sets up a table named 'bitwise_example' with various data types and inserts sample data for demonstrating the BITAND_AGG function. ```sql CREATE OR REPLACE TABLE bitwise_example (k INT, d DECIMAL(10,5), s1 VARCHAR(10), s2 VARCHAR(10)); INSERT INTO bitwise_example VALUES (15, 1.1, '12', 'one'), (26, 2.9, '10', 'two'), (12, 7.1, '7.9', 'two'), (14, NULL, NULL, 'null'), (8, NULL, NULL, 'null'), (NULL, 9.1, '14', 'nine'); ``` -------------------------------- ### DAYNAME_LONG_UDF Usage Example Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/general/technical-documentation/function-references/teradata/README Example of using DAYNAME_LONG_UDF to get the full name of the day of the week for a specific date. ```sql :force: SELECT PUBLIC.DAYNAME_LONG_UDF(DATE '2022-06-30'); ``` ```sql :force: 'Thursday' ``` -------------------------------- ### DAYNUMBER_OF_YEAR_UDF Example Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/general/technical-documentation/function-references/teradata/README Provides an example of using the DAYNUMBER_OF_YEAR_UDF to get the current day's number within the year. ```sql :force: SELECT DAYNUMBER_OF_YEAR(CURRENT_DATE,'ISO'); ``` ```sql :force: SELECT PUBLIC.DAYNUMBER_OF_YEAR_UDF(CURRENT_DATE()); ``` -------------------------------- ### Template Expansion Example Source: https://docs.snowflake.com/en/developer-guide/snowflake-cli/native-apps/project-definitions Example of a README file containing a template variable that gets expanded by the templates processor. ```markdown This is a README file for application package <% ctx.entities.pkg.identifier %>. ``` -------------------------------- ### Create Orders Table and Insert Data Source: https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql-tabular-functions Sets up a sample 'orders' table with product IDs and quantities sold, then inserts sample data. ```sql create or replace table orders ( product_id varchar, quantity_sold numeric(11, 2) ); insert into orders (product_id, quantity_sold) values ('compostable bags', 2000), ('re-usable cups', 1000); ``` -------------------------------- ### Create and Insert Data into Example Table Source: https://docs.snowflake.com/en/sql-reference/constructs/order-by Sets up a sample table 'my_sort_example' with numeric, string, and boolean data types for demonstrating sorting. ```sql CREATE OR REPLACE TABLE my_sort_example(a NUMBER, s VARCHAR, b BOOLEAN); INSERT INTO my_sort_example VALUES (0, 'abc', TRUE), (0, 'abc', FALSE), (0, 'abc', NULL), (0, 'xyz', FALSE), (0, NULL, FALSE), (1, 'xyz', TRUE), (NULL, 'xyz', FALSE); ``` -------------------------------- ### Create and Insert Data for Invoice Examples Source: https://docs.snowflake.com/en/developer-guide/snowflake-scripting/cursors.html Sets up the 'invoices' table with sample data for subsequent cursor examples. ```sql CREATE OR REPLACE TABLE invoices (id INTEGER, price NUMBER(12, 2)); INSERT INTO invoices (id, price) VALUES (1, 11.11), (2, 22.22); ``` -------------------------------- ### Install a Previous SnowSQL Version Source: https://docs.snowflake.com/en/user-guide/snowsql-install-config.html Use the `-v` option and specify the desired version to install an earlier SnowSQL version from the list. This example installs version 1.3.0. ```bash $ snowsql -v 1.3.0 Installing version: 1.3.0 [####################################] 100% ``` -------------------------------- ### Complete Example app.yml Source: https://docs.snowflake.com/en/developer-guide/snowflake-app-runtime/app-yml A comprehensive example of an app.yml manifest, including install, build, run, artifacts, and profile configurations. ```yaml install: commands: - [npm, ci] build: commands: - [npm, run, build] run: command: [node, dist/server.js] artifacts: - src: "dist/**" dest: "." profile: icon: assets/logo.png label: Customer Portal description: Customer portal web UI. ``` -------------------------------- ### Setup for 3-Way Join Example Source: https://docs.snowflake.com/en/sql-reference/constructs/where.html Creates and populates sample tables (departments, projects, employees) required for demonstrating multi-table joins. ```sql create table departments ( department_ID INTEGER, department_name VARCHAR, location VARCHAR ); insert into departments (department_id, department_name, location) values (10, 'CUSTOMER SUPPORT', 'CHICAGO'), (40, 'RESEARCH', 'BOSTON'), (80, 'Department with no employees yet', 'CHICAGO'), (90, 'Department with no projects or employees yet', 'EREHWON') ; create table projects ( project_id integer, project_name varchar, department_id integer ); insert into projects (project_id, project_name, department_id) values (4000, 'Detect fake product reviews', 40), (4001, 'Detect false insurance claims', 10), (9000, 'Project with no employees yet', 80), (9099, 'Project with no department or employees yet', NULL) ; create table employees ( employee_ID INTEGER, employee_name VARCHAR, department_id INTEGER, project_id INTEGER ); insert into employees (employee_id, employee_name, department_id, project_id) values (1012, 'May Aidez', 10, NULL), (1040, 'Devi Nobel', 40, 4000), (1041, 'Alfred Mendeleev', 40, 4001) ; ``` -------------------------------- ### Create and Insert Sample Data for Sales Metrics Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/general/technical-documentation/issues-and-troubleshooting/conversion-issues/sqlServerEWI Sets up a sample 'sales_metrics' table and inserts initial data for demonstration purposes. ```sql -- Create a table to store monthly sales or metric data CREATE TABLE sales_metrics ( metric_id INT PRIMARY KEY, january_value VARCHAR(35), february_value VARCHAR(35), march_value VARCHAR(35) ); -- Insert sample data INSERT INTO sales_metrics (metric_id, january_value, february_value, march_value) VALUES (1, 'sales-jan-1', 'sales-feb-1', 'sales-march-1'), (2, 'sales-jan-2', 'sales-feb-2', 'sales-march-2'); ``` -------------------------------- ### DataFrame Initialization for cumcount Example Source: https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/1.23.0/modin/pandas_api/snowflake.snowpark.modin.plugin.extensions.groupby_overrides.SeriesGroupBy.cumcount.html Initializes a DataFrame used in the cumcount examples. This setup is required before applying the cumcount method. ```python >>> df = pd.DataFrame([['a'], ['a'], ['a'], ['b'], ['b'], ['a']], ... columns=['A']) >>> df A 0 a 1 a 2 a 3 b 4 b 5 a ``` -------------------------------- ### Create and Load Tables for Merge Example Source: https://docs.snowflake.com/en/sql-reference/sql/merge.html Sets up the initial target and source tables with sample data for demonstrating MERGE operations. ```sql CREATE OR REPLACE TABLE merge_example_target_orig (k NUMBER, v NUMBER); INSERT INTO merge_example_target_orig VALUES (0, 10); CREATE OR REPLACE TABLE merge_example_src (k NUMBER, v NUMBER); INSERT INTO merge_example_src VALUES (0, 11), (0, 12), (0, 13); ``` -------------------------------- ### Get Hostname Response Example Source: https://docs.snowflake.com/en/user-guide/snowpipe-streaming/snowpipe-streaming-high-performance-rest-api Example JSON response when successfully retrieving the hostname for the Snowpipe Streaming REST API. ```json { "hostname": "string" } ``` -------------------------------- ### Snowflake SQL LEN Function Example Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/translation-references/transact/transact-built-in-functions Example of using the LEN function in Snowflake SQL to get the length of a string. ```sql SELECT LEN('Sample text') AS LEN; ``` -------------------------------- ### Setup Sample Data for Joins Source: https://docs.snowflake.com/en/developer-guide/snowpark/java/working-with-dataframes Creates and populates three sample tables (sample_a, sample_b, sample_c) used for demonstrating DataFrame join operations in Snowpark Java. ```sql CREATE OR REPLACE TABLE sample_a ( id_a INTEGER, name_a VARCHAR, value INTEGER ); INSERT INTO sample_a (id_a, name_a, value) VALUES (10, 'A1', 5), (40, 'A2', 10), (80, 'A3', 15), (90, 'A4', 20) ; CREATE OR REPLACE TABLE sample_b ( id_b INTEGER, name_b VARCHAR, id_a INTEGER, value INTEGER ); INSERT INTO sample_b (id_b, name_b, id_a, value) VALUES (4000, 'B1', 40, 10), (4001, 'B2', 10, 5), (9000, 'B3', 80, 15), (9099, 'B4', NULL, 200) ; CREATE OR REPLACE TABLE sample_c ( id_c INTEGER, name_c VARCHAR, id_a INTEGER, id_b INTEGER ); INSERT INTO sample_c (id_c, name_c, id_a, id_b) VALUES (1012, 'C1', 10, NULL), (1040, 'C2', 40, 4000), (1041, 'C3', 40, 4001) ; ``` -------------------------------- ### SQL Server LEN Function Example Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/translation-references/transact/transact-built-in-functions Example of using the LEN function in SQL Server to get the length of a string. ```sql SELECT LEN('Sample text') AS [LEN]; ``` -------------------------------- ### Create and Load Table for QUALIFY Examples Source: https://docs.snowflake.com/en/sql-reference/constructs/qualify This snippet creates and populates a sample table 'qt' used in subsequent QUALIFY clause examples. ```sql CREATE TABLE qt (i INTEGER, p CHAR(1), o INTEGER); INSERT INTO qt (i, p, o) VALUES (1, 'A', 1), (2, 'A', 2), (3, 'B', 1), (4, 'B', 2); ``` -------------------------------- ### Snowflake SQL CHAR Example Source: https://docs.snowflake.com/en/migrations/snowconvert-docs/translation-references/transact/transact-built-in-functions Example of using the CHAR function in Snowflake SQL to get a character from the ASCII table. ```sql :force: SELECT CHAR(170) AS SMALLEST_A; ``` -------------------------------- ### Create and Populate Week Examples Table Source: https://docs.snowflake.com/en/sql-reference/functions-date-time.html Sets up a table with sample dates to demonstrate week-related function behavior under different parameter settings. ```sql CREATE OR REPLACE TABLE week_examples (d DATE); INSERT INTO week_examples VALUES ('2016-12-30'), ('2016-12-31'), ('2017-01-01'), ('2017-01-02'), ('2017-01-03'), ('2017-01-04'), ('2017-01-05'), ('2017-12-30'), ('2017-12-31'); ```