GenAI for SQL & ETL: Build Multimodal AI Workflows at Scale
Summary
- Multimodal AI in SQL Workflows: Apply powerful language and vision models directly within SQL and ETL pipelines without endpoints or infrastructure management overhead.
- Scale-Ready GenAI Architecture: Databricks AI Functions enable scalable, declarative, and secure processing of unstructured data—documents, images, text—directly in production workflows.
- Cost-Effective Model Access: Run state-of-the-art LLMs like GPT-4, Claude Sonnet 4, and Llama 4 on enterprise data with built-in optimization for cost and reliability.
GenAI for SQL & ETL: Build Multimodal AI Workflows at Scale

Talk by Ahmed Bilal, Staff Product Manager, Databricks ; Colton Peltier, Staff Data Scientist, Databricks
Enterprises generate massive amounts of unstructured data — from support tickets and PDFs to emails and product images. But extracting insight from that data requires brittle pipelines and complex tools. Databricks AI Functions make this simpler. In this video, you’ll learn how to apply powerful language and vision models directly within your SQL and ETL workflows — no endpoints, no infrastructure, no rewrites. We’ll explore practical use cases and best practices for analyzing complex documents, classifying issues, translating content, and inspecting images — all in a way that’s scalable, declarative, and secure. What you’ll learn: How to run state-of-the-art LLMs like GPT-4, Claude Sonnet 4, and Llama 4 on your data How to build scalable, multimodal ETL workflows for text and images Best practices for prompts, cost, and error handling in production Real-world examples of GenAI use cases powered by AI Functions
Databricks Named a Leader in the 2025 Gartner® Magic Quadrant™ for Data Science and Machine Learning Platforms: https://www.databricks.com/blog/databricks-named-leader-2025-gartner-magic-quadrant-data-science-and-machine-learning
Build and deploy quality AI agent systems: https://www.databricks.com/product/artificial-intelligence
See all the product announcements from Data + AI Summit: https://www.databricks.com/events/dataaisummit-2025-announcements
Chapters
0:00The unstructured data challenge2:46Bridging the gap with AI5:33Introduction to AI functions7:42Demo: Text and data extraction11:57Demo: Multimodal insights14:14Production workflows with Lakeflow19:59Best practices for reliability21:40Technical evaluation and scaling29:58Implementation strategy33:43Conclusion and wrap-up
FAQs
How do Databricks AI Functions simplify working with unstructured data?
Databricks AI Functions enable running powerful language and vision models directly in SQL and ETL workflows, eliminating the need to build separate infrastructure or endpoints. This simplicity allows organizations to extract insights from documents, images, and text at scale without architectural complexity.
What are practical use cases for multimodal AI in ETL?
Practical use cases include analyzing support tickets and complex documents, classifying product issues, translating content, inspecting product images for defects, and extracting structured data from unstructured sources. These applications automate manual review processes and accelerate decision-making.
Which LLMs are supported by Databricks AI Functions?
Databricks AI Functions support state-of-the-art models including GPT-4, Claude Sonnet 4, and Llama 4. This variety enables organizations to choose the best model for their specific use case while managing costs and performance.
What best practices ensure reliable AI Function deployments?
Best practices include careful prompt engineering, implementing error handling for edge cases, monitoring cost per operation, validating model outputs for accuracy, and scaling incrementally. These practices ensure production deployments remain reliable and cost-effective.
Full transcript
0:00 The unstructured data challenge
All right. Um, hello everyone. I'm here with Colton. We both work on AI at data bricks. So today we will be talking about how you can turn unstructured data, text, images, documents to insights just by using SQL in your ETL workflows. So let's start with a quick cut check. Just show of hands. How many of you have been asked to pull insights from some sort of like long form text, documents, emails, a folder full of images?
- I heard 60. 90. All right. Okay. Cool. That's awesome. Seems like you already have seen my slide. Okay. So, yes. So, 90% of enterprise data is unstructured. So, what is really inside that 90%. Um, all sort of like stuff they are contracts, support tickets, documents, slides, PDFs, audio transcriptions, uh video files, social media. But what do really businesses want to do with this? Uh they want to think two they want to do two things.
First they want to extract insights like summarize documents, analyze sentiments, transcribe audio files, detect defects in photos and stuff like that. And the goal really here is to automate manual reviews, make decisions faster, and just kind of improve the overall quality of the decisions. The other thing they want to do is to automate and build chat bots and assistants. And this means like turning unstructured data to structured data so that chatbot can answer questions and that data can be used to automate business workflows.
But here's kind of what the challenge is. Um while 90% of the enterprise data is unstructured 90% of our tools every data tools that we use dashboard SQL ETL were created for rows and columns. So that's the that's a gap that's a mismatch and that's what we want to talk about today. So uh I do want to make it real. Uh, I want all you to imagine that you work for an online retail company. You sell consumer electronics devices and your your website or your internal platform gets like thousand of customer reviews every day.
2:46 Bridging the gap with AI
Some are long form text messages. Some just say doesn't turn on. Some are blurry photos of screenshots or um product photos. And your product ops teams want to know what are the most common issues? Um how um um how are things are going across different product lines? Are there any safety complaints? So how do you solve this? And remember all of this is unstructured text with some images. All right, let's look at um some of the ways on how you can solve this.
We'll plot those on a 2x2 matrix. On the x-axis, we have ease of use. How easy are the tools? Can you use it yourself? Can you integrate those tools in your existing workflows? And then on the y-axis, we have governance. Can you use those tools while keeping your data secure and governed? All right. So, one of the way to kind of solve this problem is to use traditional ML. So, this is where you go and hire an expert, build, train and deploy a model.
Every time you get a new use case, you have to start from scratch. So, these are really expensive, slow, and hard to use. And governance, uh, maybe, you know, if you're able to stitch together different tools, you might be able to get some All right. Then we have LLM platforms. So LLMs actually changed the game quite a bit. You no longer have to train and tune a model. You have very powerful models that you can use across wide variety of use cases.
But are they easy to use? I mean let's look at the steps that you have to follow to apply Genai on your data with some of the leading LLM providers. So first you have to prep your data. Then you have to export it and here goes your governance. Then you have to run the job. Uh you often have to wait for 24 hours to get the results back. Once you have your results, you have to ingest those responses back in and then merge with your original data.
And during all this process, your data is flying all around. So zero observability, zero lineage. So where we want to go is is is on the top left side. This is where you get ease of use and and good governance. So how do we get there? Let's break it down from the perspective of people doing the work. Data scientists, data analysts, data engineers. So first they want something which is easy to use. So they live in SQL, Python, notebook, ETL.
5:33 Introduction to AI functions
They want to be able to integrate Genai into their existing workflows. Secondly, want they want something that they can run at scale. They don't want to manage like APIs rate limits. They definitely don't want to manage GPUs. Whether it's 100 rows or it's 1 million rows, it should just work. And then if you are applying GEI on your production data, it better must be secure and trusted. So you need access control, observability, lineage, all those sort of things.
So that's really what the bar is. That's what you know what it means when teams say they want to run Gen AI on production data. So how are we solving it? All right. So on the left side you can see all what you have to do to apply GNAI on your data with external LLM platforms. Uh prep your data, export it, uh ingest it back. Now I want I want you to look at the right side with AI functions. You can replace all of this with just one line of SQL or Python.
And this is how it looks like. You call AI query, you pick your model, you write your prompt, and then you can point it to your data. That's all. That's what you have to do. And now you can take this line of code and you can run it everywhere across databicks like notebooks, DBSQL, workflows, dashboards, lakeflow. It runs everywhere. And the really cool thing about this is that it scales serverlessly to support millions of rows.
In fact, the more data you send it, the more it will scale. And then most importantly, it applies directly on your govern data without moving it around. So you benefit from all the governance capabilities that data bricks have built. So let me show you how simple it is to actually get started with AI functions. All right, let me first just show you how these customer reviews look like. Um, yeah, so these are like really long.
7:42 Demo: Text and data extraction
Um, full of typos, really hard to understand. So what you could do here is just come here and write AI. All right, I don't even have to write and you could just run it. All right, so these are your original customer reviews and now you have a very neat oneline summary of these reviews. I mean I ran it on like 10 rows but I could just remove this limit and then I can run this thing on my entire data set. So I went from you know prototyping to just running it on my entire data set and this thing is like really really fast.
All right now let's do a little bit more uh more custom thing. Let's say you want to extract few information from the review. Say you want to extract sentiment, issue type and severity of of the reviews that you are getting. And there you can use something more custom um more custom and more generic function which we have. We call it AI query. Um so I'm going to remove this and replace it with AI query. Actually I'm so lazy.
So I'm going to just use assistant um to write that one line. All right. Okay. So I'm going to say use llama for to extract uh sentiment issue type and severity and then I want the output as JSON. L&Ms love to talk. So you have to add this thing. No other text. And they also love back ticks. So no back tick. Not exactly. Let me just accept this one. Uh but it didn't get the model right. So, I'm going to um I will have to go to the serving and just pick the right name.
All right. Um I think the prompt looks good. And then I just need to pass the text to it. actually awesome. Here we go. Um, we now have our here you can see like we have extracted few key information from our reviews. Actually, I want the output in a table. So, let me just do that. Uh, I'm going to limit this to 10 and I'm going to ask the assistant to say uh, unpack the JSON. Awesome. Here you go. Now you have your raw review converted into structured table that you can use for further analysis.
All right. So, so far we have looked at how you can use AI query with text but AI functions are not limited to text. You can actually pass PDFs and images to it. So, say someone share share share like a group of charts with you. You can actually pass these charts images to AI functions and ask the LLM to explain them. And for that, I'm going to use a notebook. You can actually use do it in DBSQL editor. I want you to look at the uh image as well.
11:57 Demo: Multimodal insights
All right. So, I'm going to just run the first two rows. Let's just run this one as well. So, here you go. We actually I pulled this thing from um Genai report by McKenzie. It's a very complicated graph um and it's kind of hard to to digest what's happening really in the chart. And so what you can really do is just pass this jar to your AI function. And just for a change, by the way, I'm using Python here. Uh you could do it in SQL as well.
Uh and the other thing that you would notice is that I'm using um an anthropic model here. And here you go. And what I'm asking really the LM is to extract a title and a short DLDR. And here you go. I have um a neat title which basically is telling like marketing leads geni adoption and then there's a short TLDDR um or kind of interesting is that it's really able to gro all the shot and um create this really short TLDDR and I ran this on one one uh image but this is also very very scalable. you just need you just can give a full folder to it and AI functions can run it on all the images uh which is what I'm doing here right so you have you have your images and then you have your title and tlddrs All right.
14:14 Production workflows with Lakeflow
So that's how easy it is to get started with AI functions. Now you all might be asking how do I take that into production and that's where lake flow comes in. So gen uh AI functions uh brings gen AI to your data and lakeflow makes it production ready. So here's how you can use AI functions in combination with lakeflow. First you can use lake flow to ingest structured and unstructured data from wide variety of uses. So the shareepoint, Google drive and so uh and a lot many other places.
Once you have your data in lakehouse then you can do your transformation and this is where AI functions comes in. So you can use AI query, AI extract, AI sentiment inside your SQL or Python transformation logic. And finally, you can run your job. Uh, and when you run your job, you actually benefit from all the lakeflow capabilities. Incremental processing, streaming, batch mode, built-in quality checks, CI/CD, observability, and lineage.
So, you really don't need any other tool to do GITL. You can just integrate AI into your everyday ETL pipeline. So we'll go back to that customer review use case. Remember we still need to solve that problem. And now since we know about AI functions and lakeflow we'll use them in production and build a pipeline and dashboard that businesses can use. So I want to first show you the dashboard the end product um and then I want to show you the lakeflow pipeline that's that's powering that dashboard.
So let's start by first looking at the dashboard. So here's what the dashboard looks like. So on the top you c you can see we are tracking monthly review stats. What how many tickets came in? How many were negative? What is the average severity score? Then below I am looking at the trends over time like how is sentiment changing over time. So for example, if I zoom in on kind negative sentiments, I can see that there was a slight uptick last month.
Then this row basically looks at top issues and how categories of products are driving those top issues. And then finally, I'm doing something really interesting here. We're also tracking which issues include images and how often those visuals confirm the issues described in the review. And this is all done with AI functions. So you can actually do visual confirmation without any manual work. And so if you go to this tab, you can actually see what the raw data looks like or what the raw uh computation looks like.
So each for each row has a review summary of the review um and the image and then an explanation whether the image matched with the issue described in the review or not. So for example for this one you can see yes the uh it the image does match with the issue described and it also there's also an explanation um that we are also computing again all with AI functions. Now let's look at the lakeflow pipeline that's powering all of it.
So I will switch here to pipelines and this is my pipeline here. All right, this is my DAG. All right, there's there's there's a lot going on here, but we'll we'll unpack this thing together. First, I am ingesting the data. Then I do sentiment analysis on it and split that into positive and negative reviews. Now, for positive reviews, I am extracting delight categories and highlights. And then for negative reviews, I'm doing like a couple of analysis.
So let me actually show you the code. All right. Um yeah. So here's here kind of the stuff I'm doing um with the negative reviews. I'm extracting the issue. Uh were there any safety issues? What was the root cause? Um I'm also trying to figure out if there were any comparator names um mentioned in the reviews. Again all of these basically analysis gives you more richer insights on your data. Uh then I'm doing this image analysis.
Again kind of cool thing is that all of them look the same. It's just like the prompts are different. And then finally I'm taking all of this data and creating a severity score. And I'm using a mix of both LM and some rule-based logic to come up with this score. So for example, if there's visual confirmation, we can give a higher score to that review so that our support team can triage those issues and can respond to those issues faster.
Again, all of this written just with SQL. Uh let's go back to the slides here. So let's just just to recap, we kind we went from unstructured data text with some images to structured trustworthy enriched data to a dashboard that business can use every day. All right. Now when it comes to geni quality and reliability super important and often becomes a dealbreaker and there are patterns, features and best practices that you can use to get reliable results from AI functions.
19:59 Best practices for reliability
And to talk about this, I'm going to hand it. Hey everyone. I work on the professional services team at data bicks. So I'm partnered with customers to help them implement their machine learning projects. And so I wanted to come here today and share with you some of the best practices I've found as I've interacted with these batch pipelines um which are performing inference. So, we offer three different types of AI functions.
The first one, you've seen a couple of these so far. They're task specific things like AI summarize, and I'll I'll show you a big list of these in a bit, but they're very specific to an individual task, and they've been tuned on the back end by data bricks to be very good at that task. The second is AI query, which you also saw blows you to specify a little more detail. So you can put your exact model you want to use.
You can experiment with different models. You can actually write the prompt yourself if you can get better results that way. You can also specify additional parameters like temperature or max tokens here as well. And finally there's agent bricks which I'm not going to talk a lot about this today. This is this was shown during the keynote. This is the new method of having data bricks automatically tune your application for you on the back end.
So before we dive in on this, I wanted to show you a notebook and kind of walk you through a couple examples here um of how you might use these functions in a real use case. So what I've done here is I've grabbed just a handful of abstracts from the summit talks this year and I put them into a spark dataf frame and put it as a temporary view with data bricks SQL. So the first use case here is to take the abstracts and let's try to generate some social media posts for them to promote them.
21:40 Technical evaluation and scaling
So the first way I'm going to do that is by using the AI summarize function. This is a task specific function. And you can see it's very straightforward. I just pass in the description in SQL and I get a summary out at the end. So you can see a few of those here. Um they're pretty short. They're good summaries. These are single line summaries, but maybe these aren't exactly what we want for a social media post. So, I want to take it a step further.
I'm going to step to AI query and try to tailor a specific prompt. But before I do that, let's talk about how we would know if this was a good summary or not. Right? So, we've generated these summaries and in the traditional ML sense, you want to be able to um evaluate things, right? You need a metric to go along with your generated component to see if it's any good or not. So there's a lot of metrics you can pick and the metrics are very task specific depending on what you're doing.
In this case, we're doing summary uh summarization. So rouge is a good contender here and I've chos chosen rouge L which is looking at the long longest subsequence of tokens that matches between the generated text and the original text. And the reason that's used for summarization is because it's kind of looking at the order of the text in the original body and it's looking for extracted tokens along the way and how well those match.
So let me show you how you would uh evaluate these generated texts. So I pull them into um the data frame here and I just pass them into MLflow evaluate. You can see the only real work I have to do here is to specify the metric I want to use and this will create an MLflow run which will log your metrics inside. So you can see I have a a mean score of 0. 19 which may be as good maybe not. And let's take it a step further and see if we can get a little bit higher of a score.
So for this I'm switching to the more general AI query function because it gives me a little more control over the outputs. So maybe for us we're thinking we need to tell the LLM this is a social media post. So I put that in the uh in the prompt there. We also tell it to make sure it includes key technologies, people, company names, etc. So hopefully this gets us a better um output that we can post on social media. So I run I run the outputs there and I I put them through ML flow and you can see my score went up quite a bit to a 34.
But really what did I get, right? Like is it actually better or not? You know, the metrics can only tell you so much. So, I got some some outputs here so you can see them. Um, they look good. Like they they look like um they're pretty good. Some are maybe a little long. Um they all seem like they have like this prepended text on the front. Like here's a social media post. And if you've worked with LLMs much, you've probably ran into this.
And now you have a whole thing ahead of you of how do you extract the actual useful text out of the big body of text you got back from the LLM? And that could be challenging, right? because it's not prepending the same text every time. It seems like it's different. So, fortunately, there is a way to do this. Um, you're not going to have to write all that custom code. AI query does allow you to specify structured output.
So, you can give a JSON schema to AI query and it will enforce a structured output on the LLM. So, in this case, I'm telling it I want a JSON structure back with just one field social media summary, which is a string. And this will allow me to really tailor what I get back and not have that prepended text. So you can see that now I'm getting um much better summaries that are going to be really easy for me to pull out.
So let's talk about one more use case here. This one is what if we want to generate better titles? You know, everyone that submits a talk at Summit, they put their abstract in, they put their title in. Um maybe some titles are better than others. Maybe we can generate some good titles. um and suggest them to users and they could use those to sort of like have catchier titles and get people more interested in their sessions.
So, what I'm doing here is I'm making a custom prompt for AI query because I really have a specific schema I want out. I want to generate a title and some keywords to help with search. And you can see I get out some pretty good stuff here. I get um generated titles. I get um keywords I can use on the web to help uh facilitate search. But again, we don't really know how good these are. And this isn't something where we can use a really easy metric like rouge because we're talking about catchiness, which is sort of this like abstract concept that maybe isn't super easy to quantify.
So what I'm going to do is I'm going to take advantage of an ML flow function called make genai metric. And this allows you to specify a custom metric with a rubric and LLM as a judge will be applied across your data using this rubric. And it can help you sort of quantify some of those more abstract concepts. In this case, I give it a little definition of what I think catchiness means. It means something to do with emotional appeal and sparking curiosity.
And then I say, rate these on a scale essentially of 0, one, or two. And now what I'm going to do is I'm going to pass through both my original generated titles. Um I'm loading these into uh into pandas here. Let me skip past that. And you can see I'm passing in my custom metric here. And then I'm just telling the elements a judge to look at this column called generated title. And I'm able to get a 1. 71 out of two, which seems pretty good to me.
Maybe you would iterate further and see if you can increase that. But this kind of shows you how you can quantify these more abstract concepts. And for the last use case, I want to show you something here. Um, what if we want to rewrite abstracts for a specific audience? So maybe you want to take an abstract and make it more attractive to data engineers for example. So first I'm going to use AI gen. And AI gen is a task specific function that we offer which just generates text.
So you're going to get a string back at the end. Um, and I essentially just say rewrite the abstract for data engineers and I get some sort of output which seems pretty good. Um, it it seems like it does talk about things that are interesting to data engineers. But what if I want something better? So AI query now offers reasoning as well for some supported models. Claude 3. 7 sonnet is one of them. And what this does is it allows the LLM to think for a bit and reason before it gives you its final output.
And this can still be done in a batch way. So one of the key components you'll want to notice here is the budget tokens down there. So budget tokens says how long the model can think, how many tokens it can use while it's reasoning. And the max tokens is the total tokens of the output including the reasoning. So I give it the same prompt, give it uh the reasoning capability and I get some new um outputs here which hopefully are better.
But I need to check that they actually are better. So I'm going to make another genai metric and this metric is going to evaluate how relevant these abstracts are for data engineers. And so I gave it some criteria here that you know data engineers care about SQL, they care about ETL pipelines, big data tooling and I give it a rubric to score these on. So then I run both the original data set with AI gen. I get a 4. 42 out of five and I run the new one with reasoning where I get a 4.
71 out of five. And so you can see you can get better gain sometimes by using reasoning especially on the complex tasks. So, let me hop back over to the slides and I can talk a little bit more detail about these. So, there's 12 altogether um functions offered. There's nine text related functions, numeric forecasting, vector search, and then there's the generic AI query function. You can see all of the task specific functions on the right here except for AI forecast or I'm sorry, uh vector search.
29:58 Implementation strategy
I didn't include that one. Um, and they let you do anything from masking PII with AI mask to analyzing sentiment of text to extracting key components from your text or even fixing grammar. So, you can see at the bottom down there, um, translating between languages is also supported. Now, one of the coolest things about these built-in functions is that the model in the backend will continue to be updated. Um, and so that's really great because you essentially get the power of the data bricks engineering team that's building on these and continually retraining on lots of data and you're getting the best function all the time.
So my general flow uh you can see it here is when I'm first approaching a task, I check to see if an AI function can do it out of the box. If it can, I start there and I evaluate the performance. if it can't do that task, if there's no AI function available or if I need more more customization, I'll switch to AI query. Um, one thing I will say too about the built-in AI functions is they already return an intuitive type of data.
So, you'll get structured data back without having to write any additional logic around getting that structured data, without having to specify JSON schemas. Um, or you'll get strings if it makes sense or for AI forecast, you'll get numeric data. The other limitation here is the task specific functions are English only right now. So if you're doing multilingual stuff, you will need to switch to AI query. Or if you just want more control over your prompting, your parameters or which model you want to use under the hood for evaluating performance.
We talked a little bit about this. You need to pick a metric. Um the same as classical ML. You pick a metric, you create a ground truth data set, and you leverage MLflow to do this at scale. So, here's a little bit more detail on the structured output. You can see uh an example there, and you can get um decently complex with the structured output and still get good results. Um it does seem like the flatter your structure, the better results I got.
So, if you really nest the JSON, it does start to take a little bit longer to enforce that. Um, one use case I have seen here, um, customers use this for is for binary classifications on data. So, they'll look at, um, some body of text and they'll say, did the customer ask about X, Y, or Z? And they'll have multiple of these um, under the hood and it's getting binary labels out at the end. Or if you need different types of fields, right?
So maybe you want to extract um um something in terms of a JSON string um for one value and then maybe for another one you want a numeric value that's pulled like a page number or something um you would want structured output as well. And then there's model reasoning. So this is only for cloud 3. 7 sonnet today. Um it is rolling out for other models as well. Actually, is this supported for llama 3. 3? Work for cloud 4, but not should work for cloud 4.
Okay. Yeah. So, it is rolling out. Um, and this is super powerful for complex tasks. Of course, you do use more tokens here. So, there is a cost constraint there. So, this isn't what I jump to immediately, but if I'm having trouble completing something, I'll give this a shot. So, finally, couple last notes. Um, Bal talked a lot about unstructured data. There's so much unstructured data out there. Um, you know, there's a lot of focus recently on these really fast iterative chat agents, but there's a huge trove of this data that needs processed and that you can gather a lot of insights from.
33:43 Conclusion and wrap-up
And that's where these AI functions really shine doing batch inference. You can finally query it inside of SQL and Python. And you can even do multimodal, which is fantastic for people that are trying to process images. So over a coffee break, please do try out AI query, try out the task specific functions, um, and learn more about productionalization while you're here and by leveraging Lake Flow. Thank you so much.
Learn more about the Databricks Data and AI platform.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.