Week 140 - Cortex (AI / ML)

Your company recently migrated a set of invoice records from multiple vendors into Snowflake. Each line item includes a free-text description of services provided — but there’s no consistent naming or structure across entries. To support financial reporting and vendor analysis, your team needs to classify each service description into a standard list of categories maintained by Finance.

Manually tagging hundreds of rows isn’t scalable. Luckily, you've just discovered Snowflake Cortex, which lets you run LLM-powered classification directly in SQL using the CLASSIFY_TEXT() function.

Your challenge: write a query that automatically assigns each service description to its most appropriate category.

The expected result

Hint: Use a CTE to aggregate the category names into an array using ARRAY_AGG(), then cross join it into the invoice data so each row has access to the full list of options for classification.

P.s. does it look familiar? In that case, it was nice to meet you at #SnowflakeSummit2025 in San Francisco :)

Previous
Previous

week 141 - Cortex (AI / ML)

Next
Next

Week 139 - Cortex (AI / ML)