Loading Databricks updates...
← All video guides
Generative AI & Agents

SQL AI Functions: Sentiment, Entity Extraction, Classification

Learn how to use Databricks AI functions to add natural language processing to SQL queries without writing Python or ML code.

In short

Learn how to use Databricks AI functions to add natural language processing to SQL queries without writing Python or ML code. Covers 8 functions: sentiment analysis, entity extraction, grammar correction, text classification, text generation, data masking, summarization, and translation.

Source: official Databricks documentation · Databricks announcement

Key takeaways

  • AI_ANALYZE_SENTIMENT classifies text as positive, negative, or neutral automatically.
  • AI_EXTRACT retrieves specified entities like names, locations, and organizations.
  • AI_CLASSIFY_TEXT assigns text to custom labels defined by user.
  • AI_MASK obscures sensitive information like PII and salary data from results.
  • AI functions run on SQL Warehouses using Mixtral-8x7b model backed.
  • Multiple AI functions compose together in single queries for complex workflows.

Chapters

  • 0:00 — Databricks AI Functions for SQL Analysts
  • 0:32 — Sentiment Analysis: Classify positive, negative, neutral
  • 1:04 — Entity Extraction: Extract names, places, companies
  • 1:34 — Grammar Correction: Fix spelling and syntax errors
  • 2:06 — Combining AI Functions: Compose multiple queries
  • 2:40 — Text Classification: Assign text to custom categories
  • 3:10 — Text Generation: Create summaries and responses
  • 3:40 — Data Masking: Mask sensitive information (PII, salary)
  • 4:11 — Text Summarization: Condense long text to key points
  • 4:42 — Translation: Convert English text to Spanish
  • 5:16 — Model Details and Resources

Frequently asked questions

What are Databricks AI functions?

SQL-callable functions adding NLP capabilities like sentiment, entity extraction, classification, and masking to queries without writing Python or ML code.

How can AI functions be used together?

Combine them in pipelines: extract entities from emails, classify sentiment to understand customer mood, mask PII before sharing reports to external users.

Which model powers these functions?

Mixtral-8x7b open source model providing cost-effective inference without requiring custom ML infrastructure or external API costs.

Full transcript

Auto-generated from the video and lightly edited for readability. Timestamps link to the moment in the video.

Show full transcript (15 segments)

0:01hi folks with all the incredible progress made in the space of large language models several customers have asked how they can enable their SQL analyst to leverage this powerful technology in their day-to-day workflows to do so data braks has released several AI functions that I will show you right now as you can see over here um using my

0:27notebook what I did call those AI functions and those AI functions for now only support SQL warehouses so I will call my SQL Warehouse in note in a notebook and let me start with the first one the first function is AI analyze sentiment so this function will perform sentiment analysis over an input uh text

0:52and as you can see over here I love I mention that I love my job more than my wife which is a negative sentiment of course it if I do switch this more than my job I will have a positive outcome which is super great we still have faith in humanity the second function is called

1:14AI extract so this function will extract entities specified by a label from a given text you can think about for example let's suppose you getting several emails and you want to extract some important information in order to store them somewhere and that's the case over here you just call the AI extract so I mention here USF Mar is from

1:36Morocco and is currently a solution architect at data briak based in Paris so I'm asking the model to extract the name of the person the nationality and the company and that's the case as you can see the person is USF nationality more broko and the company database the other function is AI fixed

1:58grammar so this function will correct grammatical errors given in a SQL text so as you can see here my English is so good I feel I am a native speaker and that's the correct one my English is so good I feel I am native speaker of course you can combine those functions for example you can get an email fix the fix the errors

2:22extract the entities and also get the sentiment analysis for example maybe it's support case and you want to know whether the customer is angry or or maybe happy and what are the most important piece there you have also AI classify and this one is given uh some labels you're going to

2:45input the model will try to assess or to assess with which label it will assign to this specific one so as you can see over here I did mention that my LTAP is broken and I have two labels bad not bad and you can see this it's classifies this one as a bad one we have the AI gen so this function will answer questions

3:08or a prompt by a user and that's what I did over here so I'm asking the model to generate a text praising Morocco in 10 words and that's the case Morocco VI vibrant culture stunning landscape Rich history then we have also AI mask so this function of course will mask some specific entities based on the

3:31input so over here I'm saying that I live in bzel and my salary is 10 million euros per year of course I'm kidding and I'm specifying that this function should uh mask the city and the salary and that's the case if I run this I will have the the uh mask test so use FES

3:56in mas and his salary is and you have the answer you you can think about this for example if you have some important some sensitive data so you can get the in the right the plain text create a view or like create a view and this view will be filled with mask data to make sure that sensitive data are not uh visible to someone for example and

4:20then we have of course the AI summarize of course this function will summarize uh a text and as you can see over here so I have a text about Apache spark I will have the summary over here Apache spark is a unified multilanguage analytics engine for large scale data processing with ML Graphics real time

4:42data support and of course last but not least we have ai translate so this function is translating uh text so far it supports only English and Spanish but of course course it will evolve and that's the okaye so select AI translate I speak

5:04Spanish very well I I specify the language so the results is those functions uh realize on the paper token of models and they are backed by mix HX 7B inct don't hesitate to try them thank

5:28you

Official Databricks resources

Related

Databricks Answers

Looking for a quick, source-backed answer? Browse Databricks Answers on GenAI, agents & Vector Search — direct, documentation-validated answers to common Databricks questions, curated by Youssef Mrini, Senior Developer Advocate at Databricks.