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 (coming soon) 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.
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
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. In Snowsight, create a SQL Worksheet and open images.sql to execute all statements in order from top to bottom.
Step 4. Click on cortex_aisql.ipynb to download the Notebook from GitHub. (NOTE: Do NOT right-click to download.)
Step 5. In Snowsight:
DASH_DB
and DASH_SCHEMA
Run on warehouse
DASH_WH_S
SYSTEM$STREAMLIT_NOTEBOOK_WH
Step 6. Open Notebook
Here's the code walkthrough of the cortex_aisql.ipynb notebook that you downloaded and imported into your Snowflake account.
Once the status changes from Starting to Active, run through all the cells from top to bottom.
Cell Import_Libraries
Import libraries required for running cells in the notebook.
Cell AI_COMPLETE
Identify customer issues across text and image data using AI_COMPLETE() and see how the SQL operators work seamlessly across all modalities.
Cell Preview_Data
Notice that native FILE datatype allows for consolidating all data formats into one table.
AI_FILTER
Semantically "JOIN" customer issues with existing solutions using JOIN ... ON AI_FILTER().
AI_AGG
Get aggregated insights across multiple rows using AI_AGG().
AI_CLASSIFY
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_PY_FILES encryption = (TYPE = 'SNOWFLAKE_SSE') directory = ( ENABLE = true );
Step 2. Use Snowsight to upload snowbooks_extras.py on stage 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.
Before importing snowbooks_extras
After importing snowbooks_extras
– you will need to click twice (not exactly a double-click though :)) to see the enlarged image as shown.
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.