Cortex AISQL reimagines SQL into an AI query language for multimodal data, bringing powerful AI capabilities directly into Snowflake's SQL engine. It enables users to build scalable AI pipelines across text, images, and audio using familiar SQL commands. With native support for multimodal data through a new FILE datatype, Cortex AISQL seamlessly integrates AI operators with traditional SQL primitives like AI_FILTER and AGGREGATE, allowing analysts to process diverse data types more efficiently and cost-effectively while maintaining enterprise-grade security and governance.
Cortex AISQL bridges the traditional divide between structured and unstructured data analysis, eliminating the need for separate tools and specialized skills.
It delivers three key benefits:
By unifying all data types in a single platform with zero setup required, Cortex AISQL democratizes AI-powered analytics across the enterprise.
Cortex AISQL benefits organizations across industries dealing with diverse data types including:
Business analysts can extract insights without AI expertise, data engineers can build simpler pipelines, and data scientists can create richer feature sets, all using familiar SQL.
NOTE: Individual functions in the Cortex AISQL suite are Preview Features. Check the status of each function on its SQL reference page before using it in production. Functions not marked as preview features are generally available (GA) and can be used in production.
You'll learn how to use powerful operators of Cortex AISQL to analyze multimodal data within Snowflake using natural language.
Snowflake Notebook that helps you get started with using Cortex AISQL with multimodal data across test, images, and audio files.
Step 1. In Snowsight, create a SQL Worksheet and open setup.sql to execute all statements in order from top to bottom.
Step 2. Download sample images files and use Snowsight » Data » Add Data » Load files into a Stage to upload them to DASH_DB.DASH_SCHEMA.DASH_IMAGE_FILES
stage created in step 1.
Step 3. Download sample audio files and use Snowsight » Data » Add Data » Load files into a Stage to upload them to DASH_DB.DASH_SCHEMA.DASH_AUDIO_FILES
stage created in step 1.
Step 4. In Snowsight, create a SQL Worksheet and open images.sql to execute all statements in order from top to bottom to create IMAGES table.
Step 5. In Snowsight, create a SQL Worksheet and open audio.sql to execute all statements in order from top to bottom to create VOICEMAILS table.
Step 6. Click on cortex_aisql.ipynb to download the Notebook from GitHub. (NOTE: Do NOT right-click to download.)
Step 7. In Snowsight:
DASH_DB
and DASH_SCHEMA
Run on warehouse
DASH_WH_S
SYSTEM$STREAMLIT_NOTEBOOK_WH
Step 8. Open Notebook
Here's the code walkthrough of the cortex_aisql.ipynb notebook that you downloaded and imported into your Snowflake account. NOTE: Individual functions in the Cortex AISQL suite are Preview Features. Check the status of each function on its SQL reference page before using it in production. Functions not marked as preview features are generally available (GA) and can be used in production.
Once the status changes from Starting to Active, run through all the cells from top to bottom.
Import libraries required for running cells in the notebook.
Identify customer issues across text, image, and audio data using AI_COMPLETE() and AI_TRANSCRIBE() to see how the SQL operators work seamlessly across all modalities.
Notice that native FILE datatype allows for consolidating all data formats into one table.
Semantically "JOIN" customer issues with existing solutions using JOIN ... ON AI_FILTER().
Get aggregated insights across multiple rows using AI_AGG().
Classification of labels that can be used in downstream applications using AI_CLASSIFY(). For example, to train ML models.
==================================================================================================
If you'd like to see images displayed in the Notebook as part of the consolidated data in Preview_Data cell, follow these instructions.
Step 1. In a SQL worksheet, execute the following statement to create a Snowflake managed internal stage to store the sample python files.
create or replace stage DASH_DB.DASH_SCHEMA.DASH_PY_FILES
encryption = (TYPE = 'SNOWFLAKE_SSE')
directory = ( ENABLE = true );
Step 2. Use Snowsight to upload snowbooks_extras.py on stage DASH_DB.DASH_SCHEMA.DASH_PY_FILES.
Step 3. Reopen existing cortex_aisql.ipynb Notebook, and on the top right click on Packages » State Packages and enter @DASH_DB.DASH_SCHEMA.DASH_PY_FILES/snowbooks_extras.py and then click on Import.
Step 4. If the session is Active, click on it to end the current session. Otherwise, click on Start to start a new session which will also update the packages list and include our custom package snowbooks_extras.
Step 5. Add import snowbooks_extras
to the libraries list under Import_Libraries and run the cell.
Step 6. Now if you run Preview_Data cell, you will see images displayed in INPUT_FILE column as shown below.
Congratulations! You've successfully created a Snowflake Notebook that helps you get started with using Cortex AISQL with multimodal data.
You've learned how to use powerful operators of Cortex AISQL to analyze multimodal data within Snowflake using natural language.