{"id":805,"date":"2025-11-02T19:00:49","date_gmt":"2025-11-02T19:00:49","guid":{"rendered":"https:\/\/datadandies.nl\/?p=805"},"modified":"2025-11-02T19:01:21","modified_gmt":"2025-11-02T19:01:21","slug":"extract-insights-from-freeform-values-in-a-column-in-snowflake-using-snowflake-cortex-ai","status":"publish","type":"post","link":"https:\/\/datadandies.nl\/index.php\/2025\/11\/02\/extract-insights-from-freeform-values-in-a-column-in-snowflake-using-snowflake-cortex-ai\/","title":{"rendered":"Extract insights from freeform values in a column in Snowflake using Snowflake Cortex AI"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Ever wanted to extract insights from freeform values in a table?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Snowflake AI might be able to assist with that. Snowflake Cortex is a part of the AI features in Snowflake.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Snowflake Cortex according to the documentation is&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u201c<strong>&#8230; <\/strong>a suite of AI features that use large language models (LLMs) to understand unstructured data, answer freeform questions, and provide intelligent assistance.\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Several interesting functions are present in a notebook that has been created by Snowflake as a demo-notebook:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SNOWFLAKE.CORTEX.SENTIMENT( FREE_FORM_COLUMN )<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SNOWFLAKE.CORTEX.SUMMARIZE( FREE_FORM_COLUMN )<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SNOWFLAKE.CORTEX.AI_CLASSIFY( FREE_FORM_COLUMN, [&#8216;category1&#8217;, &#8216;category2&#8217;] )<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">See the screenshot below for an example of how these functions work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The demo notebook is called \u201cAnalyze sentiment in unstructured data\u201d and again, I did not create it. Snowflake did, and it should be available to you in your account. Are you using these functions and if so, for what purpose?<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"447\" data-id=\"806\" src=\"https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/11\/20251103-Snowflake-cortex-functions-SUMMARIZE-AI_CLASSIFY-and-SENTIMENT-1024x447.png\" alt=\"\" class=\"wp-image-806\" srcset=\"https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/11\/20251103-Snowflake-cortex-functions-SUMMARIZE-AI_CLASSIFY-and-SENTIMENT-1024x447.png 1024w, https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/11\/20251103-Snowflake-cortex-functions-SUMMARIZE-AI_CLASSIFY-and-SENTIMENT-300x131.png 300w, https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/11\/20251103-Snowflake-cortex-functions-SUMMARIZE-AI_CLASSIFY-and-SENTIMENT-768x335.png 768w, https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/11\/20251103-Snowflake-cortex-functions-SUMMARIZE-AI_CLASSIFY-and-SENTIMENT-1536x671.png 1536w, https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/11\/20251103-Snowflake-cortex-functions-SUMMARIZE-AI_CLASSIFY-and-SENTIMENT-2048x894.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/figure>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1.3rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * 1.3rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">SQL<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"SELECT \n  REVIEW_ID,\n  REVIEW,\n  LEN(REVIEW) AS LENTH_REVIEW, -- Length of the review.\n  SNOWFLAKE.CORTEX.SUMMARIZE(REVIEW) AS SUMMARY, -- Summary of the review.\n  LEN(SUMMARY) AS LEN_SUMMARY, -- Length of the summary of the review. Still quite long, apparently this function is not a a fan of one-liners. Should take lessons from Arnold. \n  SNOWFLAKE.CORTEX.SENTIMENT(REVIEW) AS SENTIMENT, -- Extracts the sentiment of this review\n  SNOWFLAKE.CORTEX.AI_CLASSIFY(REVIEW, ['negative', 'positive']) AS CATEGORY_RAW, -- Classify a review with either the category 'negative' or 'positive'. Raw value from the function.\n  REPLACE(SNOWFLAKE.CORTEX.AI_CLASSIFY(REVIEW, ['negative', 'positive']):labels[0], '&quot;') AS CATEGORY -- Classify a review with either the category 'negative' or 'positive'.\nFROM TRUCK_REVIEWS\nLIMIT 15;\" style=\"color:#D4D4D4;display:none\" aria-label=\"Kopieer\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  REVIEW_ID,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  REVIEW,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  <\/span><span style=\"color: #DCDCAA\">LEN<\/span><span style=\"color: #D4D4D4\">(REVIEW) <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> LENTH_REVIEW, <\/span><span style=\"color: #6A9955\">-- Length of the review.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  SNOWFLAKE.CORTEX.SUMMARIZE(REVIEW) <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> SUMMARY, <\/span><span style=\"color: #6A9955\">-- Summary of the review.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  <\/span><span style=\"color: #DCDCAA\">LEN<\/span><span style=\"color: #D4D4D4\">(SUMMARY) <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> LEN_SUMMARY, <\/span><span style=\"color: #6A9955\">-- Length of the summary of the review. Still quite long, apparently this function is not a a fan of one-liners. Should take lessons from Arnold. <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  SNOWFLAKE.CORTEX.SENTIMENT(REVIEW) <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> SENTIMENT, <\/span><span style=\"color: #6A9955\">-- Extracts the sentiment of this review<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  SNOWFLAKE.CORTEX.AI_CLASSIFY(REVIEW, [&#39;negative&#39;, &#39;positive&#39;]) <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> CATEGORY_RAW, <\/span><span style=\"color: #6A9955\">-- Classify a review with either the category &#39;negative&#39; or &#39;positive&#39;. Raw value from the function.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  <\/span><span style=\"color: #DCDCAA\">REPLACE<\/span><span style=\"color: #D4D4D4\">(SNOWFLAKE.CORTEX.AI_CLASSIFY(REVIEW, [&#39;negative&#39;, &#39;positive&#39;]):labels[0], <\/span><span style=\"color: #CE9178\">&#39;&quot;&#39;<\/span><span style=\"color: #D4D4D4\">) <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> CATEGORY <\/span><span style=\"color: #6A9955\">-- Classify a review with either the category &#39;negative&#39; or &#39;positive&#39;.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> TRUCK_REVIEWS<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">LIMIT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">15<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#1E1E1E;color:#c7c7c7;font-size:12px;line-height:1;position:relative\">SQL<\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Ever wanted to extract insights from freeform values in a table? Snowflake AI might be able to assist with that. Snowflake Cortex is a part of the AI features in Snowflake. Snowflake Cortex according to the documentation is&#8230; \u201c&#8230; a suite of AI features that use large language models (LLMs) to understand unstructured data, answer&hellip;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/datadandies.nl\/index.php\/2025\/11\/02\/extract-insights-from-freeform-values-in-a-column-in-snowflake-using-snowflake-cortex-ai\/\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[65,40],"class_list":["post-805","post","type-post","status-publish","format-standard","hentry","category-blog","tag-ai","tag-snowflake"],"_links":{"self":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/comments?post=805"}],"version-history":[{"count":2,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/805\/revisions"}],"predecessor-version":[{"id":808,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/805\/revisions\/808"}],"wp:attachment":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/media?parent=805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/categories?post=805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/tags?post=805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}