Analyzing Data Using Text-to-SQL
This tutorial walks you through enabling and using Dremio's Text-to-SQL experience.
Dremio's Text-to-SQL experience allows you to effortlessly convert natural language queries into SQL directly within the SQL Runner. The Text-to-SQL translation is based on a semantic understanding of metadata and data, resulting in the industry’s most accurate SQL generation.
Step 1. Enable the Generative AI Features
Opting into and enabling Generative AI provides you access to the Text-to-SQL experience, generated labels and wikis, and other features powered by Generative AI as they become available.
To enable Generative AI:
- Navigate to Project Settings > Preferences and toggle on Generative AI.
This feature set is in preview. It will allow this entire Sonar project and all users with access to the project to leverage Generative AI features. Note that these features have limited world knowledge and may occasionally generate incorrect information or produce harmful instructions or biased content. For more information, see Data Privacy.
Now you can analyze data using Text-to-SQL!
Step 2. Construct a Query Using Text-to-SQL
The Text-to-SQL experience processes natural language to produce SQL to analyze your one or more datasets.
To see this in action:
Navigate to the SQL Runner by clicking in the side navigation bar.
Click in the toolbar.
In the Data panel on the left, locate
Samples."samples.dremio.com"."NYC-taxi-trips-iceberg". Drag and drop the table into the Datasets to analyze field.
In the field labeled Type in a question or message, copy and paste the question below and click Generate.Sample question
What's the average tip for a two-passenger ride?
SQL is generated for you, so all you have to do is click Run to get the answer!tip
Try this out with multiple datasets! Add
"SampleDB"."NYC-weather"to the datasets field in addition to
Give me the number of rides people took on the day that it rained the most..
Wrap-up and Next Steps
By just asking a question, you were able to analyze data in seconds without having to worry about which functions to use or having the right SQL syntax.
To try Text-to-SQL with your data, configure your own source!
To learn more about Dremio, check out Getting Started with Dremio.
If you have questions about the concepts in this tutorial or other Dremio features, reach out to us using the chat feature in the bottom-right corner of the Dremio application.