Running AI Inside Your Database: Snowflake Cortex Ticket Triage | Hussain

Hussain explains how Snowflake Cortex runs models inside the data warehouse through SQL functions, using support ticket triage as the example. He also covers token costs, filtering before classifying, and measuring label accuracy.

1:59 video2 min readWatch on YouTube

Forty thousand support tickets sit in a Snowflake table. SQL can count them, but it cannot read them. In this video, Hussain explains how Snowflake Cortex addresses that gap by running AI directly inside the database, and walks through a small ticket triage use case that is realistic to finish.

The model comes to the data

Hussain frames Cortex as a SQL function you already know how to call, not another platform to integrate. The central idea is that the model comes to the data, not the other way around.

A warehouse is strong at structured columns such as ticket ID, timestamp and region. It is blind to the column that matters most here, the ticket body. Counting rows is easy, but knowing which tickets are angry about billing is not.

Why not build a pipeline

The usual answer is an external pipeline: export the text, send it to a model API, then load the answers back. That creates a second system and a second copy of the data. Cortex inverts this. The model runs inside Snowflake, and your existing grants still apply, so there is no new security surface to manage.

Triage in a single query

The query itself is ordinary. Three Cortex functions sit in a select list:

  • CLASSIFY_TEXT picks from a label set that you define,
  • SENTIMENT scores each ticket from -1 to +1, and
  • SUMMARIZE writes a one-line summary.

The output is just a table, produced in the same warehouse under the same grants, with three new columns you can group by. Billing complaints sorted by how angry they are becomes a dashboard query.

Where it bites

Cortex is billed per token, so a SELECT star over the whole table becomes a real invoice. The WHERE clause in the example was doing quiet but important work in limiting what gets processed. The second warning is about accuracy. The labels are not deterministic, and a guess is not accuracy until you measure it.

The verdict is that Cortex earns its place when the alternative is a pipeline you never wanted. The rule that follows is to filter before you classify and to measure before you trust the output.

Key takeaways

  • Cortex runs models inside Snowflake through SQL functions, so the model comes to the data.
  • It avoids exporting text, calling an external model API and loading results back.
  • Existing security grants continue to apply.
  • CLASSIFY_TEXT, SENTIMENT and SUMMARIZE can all run in one select list.
  • The result is an ordinary table that supports grouping and dashboard queries.
  • Billing is per token, so scanning an entire table is expensive.
  • Labels are not deterministic; measure accuracy before trusting them.

Try it yourself

Paste this into Claude: provide the schema of one text-heavy table you own, and ask for the single Cortex query that would produce the most decision-useful column. Then ask what it costs per million rows and how to validate the labels. Hussain stresses that those last two clauses are the point, because anyone can hand you the query, but nobody hands you the invoice.

Chapters

  1. 0:00Introduction: 40,000 Support Tickets and SQL Limits
  2. 0:25The Model Comes to the Data: Cortex vs External Pipelines - Ticket Triage in SQL: Classify, Sentiment, and Summarize
  3. 1:20Dashboard Queries and Keeping Data Security Grants
  4. 1:45Token Cost Warnings and Measuring Label Accuracy
Full transcript(auto-generated, with timestamps)

Introduction: 40,000 Support Tickets and SQL Limits

[0:00]Hi, I am Hussein and this video is about Snowflake Cortex running AI inside your database. 40,000 support tickets sit in a Snowflake table. SQL can count them. It cannot read them, so I asked Claude where to start. Here is the whole idea. Cortex is not another platform to integrate. It is a SQL function you already know how to call. The model comes to the data, not the other way around. Your warehouse is excellent at the structured columns, ticket ID, timestamp

The Model Comes to the Data: Cortex vs External Pipelines - Ticket Triage in SQL: Classify, Sentiment, and Summarize

[0:27]Region. It is blind to the one that matters, the body. Counting rows is easy. Knowing which ones are angry about billing is not. The usual answer is a pipeline. Export the text, send it to a model API, load the answers back, a second system, a second copy of your data. Cortex inverts it. The model runs inside Snowflake and your grants still apply. So, the starter use case is small enough to finish, ticket triage. Watch how ordinary the query looks. That is the whole thing, three Cortex functions in a select list. Classify text picks from a label set you define. Sentiment scores -1 to +1. Summarize writes the one-liner. No infrastructure anywhere. The output is just a table. Same warehouse, same grants, three new columns you can group by. Billing complaints sorted by how angry they are. That is a dashboard query now. Now, where it bites. You are billed per token, so a select star over the whole

Dashboard Queries and Keeping Data Security Grants

[1:21]Table is a real invoice. That where clause was doing quiet work. The labels are not deterministic and a guess is not accuracy until you measure it. The verdict, Cortex earns it when the alternative is a pipeline you never wanted. Filter before you classify and measure before you trust it. Your turn. Paste this into Claude. Here is the schema of one text-heavy table I own. Show me the single Cortex query that would produce the most decision-useful

Token Cost Warnings and Measuring Label Accuracy

[1:45]Column. Then tell me what it costs per million rows and how to validate the labels. Those last two clauses are the point. Anyone hands you the query, nobody the invoice. Cortex in the warehouse. I am Hussein. Thanks for watching.

More from Mycroft Financial AI

Humanitarians AI Lyrical Literacy Project