AI workflows in SQL
1. AI workflows in SQL
Hello, and welcome to this chapter, where CoCo moves from answering questions about your data to doing real work with it.2. Putting AI to work
So far, you've used CoCo to explore data, check its answers, and decide what it's allowed to change. Now it'll work on text people write, like product reviews.3. Putting AI to work
Chat logs with your customers are text too.4. Putting AI to work
So are emails, and plain SQL can count all of these rows but can't read what they say.5. AI inside SQL
Snowflake's AI functions close that gap. Each one calls a language model from inside a SQL query, where the data lives.6. The main AI functions
There's a whole family of them, and this video uses four. AI classify sorts text into categories you choose.7. The main AI functions
AI sentiment scores how people feel.8. The main AI functions
AI filter keeps only the rows that match a description.9. The main AI functions
AI agg summarizes many rows at once.10. From functions to workflows
Chained together, these functions become an AI workflow, like routing customer tickets to the right team. With CoCo, you can describe the outcome in plain language, and it writes the SQL.11. Start small
Let's try it on real data. Our retailer has 177 product reviews, so we'll start small and ask CoCo to take five of them, tag each one's topic as delivery, quality, price, support, or compatibility, and score its sentiment.12. Check the labels
CoCo answers with a single query, using AI classify for the topic and AI sentiment for the tone. Five rows are quick and cheap to run, and few enough to check every label.13. Run the full workflow
Once the labels look right, ask for the full run: every review, a ranking of products from worst to best, and the results saved as a new table called review insights.14. Run the full workflow
CoCo asks before creating it, as it does for any change.15. The ranking
In the saved table, the conference speakerphone has the lowest ranking, and its main topic is quality.16. CoCo skills
CoCo also comes with skills. A skill is a packaged workflow, and it starts with instructions for one kind of task.17. CoCo skills
Next comes reference material for CoCo to read.18. CoCo skills
Finally, it adds checks to run along the way.19. CoCo skills
More than a hundred come prebuilt, and SQL is only one area. The automation skill schedules recurring CoCo runs.20. CoCo skills
Data quality sets up checks on your tables.21. CoCo skills
Machine learning handles data science and model training.22. CoCo skills
This video uses cortex AI function studio, the skill for AI functions in SQL.23. Find one with /skill
Before using a skill, look it up: slash skill opens a manager where you can search and read what each skill does and needs.24. The AI function skill
Cortex AI function studio covers Snowflake's built-in AI functions, and it can also help you build and tune custom ones.25. Why use a skill
So why use a skill when a plain request already worked? A plain request relies on what the model remembers about the syntax.26. Why use a skill
The skill follows Snowflake's own reference instead, and it checks each step before spending any credits.27. Run the skill
To run it, type a dollar sign, the skill's name, and a question. We'll ask a different one from before: which reviews say the product overheats, counted by product.28. What the skill does
The skill first confirms which AI functions your role can use.29. What the skill does
On a large table, it also estimates the token cost, though our small dataset keeps runs cheap.30. What the skill does
Then it checks the schema to find the review and product columns.31. What the skill does
Finally, it joins reviews to products and keeps only the matching reviews with AI filter.32. The answer
Ten reviews mention overheating, and seven of them are about the USB-C hub.33. Time for practice!
You've seen CoCo turn a plain request into an AI workflow, and how a skill adds Snowflake's guidance and checks to that work. Now it's time to practice.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.