- 30 Nov 2023
- 3 Minutes to read
AI Assisted SQL Querying
- Updated on 30 Nov 2023
- 3 Minutes to read
The feature will be available for general availability (GA) later in the year. Sign up here to be the first to test our text-to-SQL feature!
If you have a Starter subscription, upgrade to the Professional plan.
👤 This documentation is intended for Limited Contributors, Secondary Contributors, Primary Contributors, and Workspace Admins. Check with your Team Admin for additional access.
Generative AI has been transforming the software space, and specifically, it can be used to simplify the task of information discovery and search within the massive data collected in databases. Preset recently integrated with the OpenAI's engine to make it possible to generate SQL queries automatically from a line of English text. For users unfamiliar with the data structure and semantic layers of their database, Preset's AI Assist makes it possible to quickly retrieve answers on the data collected while still providing transparency on the SQL query generated.
The key benefits of AI Assist include:
- Quickly generating basic or complex SQL queries using natural language.
- Allowing non-technical users to explore data by writing ad-hoc queries through natural language.
At present, AI Assist is compatible with BigQuery, PostgreSQL, and Snowflake. We plan to expand support to additional databases in the near future.
Turning on AI Assist
👤 This action is intended for Team Admins. Check with your Team Admin for additional access.
In order for AI Assist to work, your workspace and database must have the AI Assist feature enabled. To turn it on for a workspace and all databases in the workspace, navigate to your workspace settings
Navigate to the AI Assist tab and check the box to turn on AI Assist.
You will also need to agree to the User Agreement to enable the feature.
Enable sample data / column-level statistics
Preset provides the ability to for users to share sample data back to OpenAI as context for more precise results.
Admins have the ability to add additional configurations and settings in JSON format.
SQL Lab Access
To use the AI in BI feature, navigate to SQL Lab from the SQL Tab at the top of your Preset application. You will now land in a new SQL Lab tab for querying your database.
Choosing the right database
You may use AI Assist on any database connected to Preset. As with all queries ran in SQL Lab, the first step is to select the right database and schema. AI Assist will take information on the database schema and each table's column names and data types to evaluate the semantic information stored in the database.
AI Assist is schema specific, so only one schema can be selected for AI Assist's querying engine.
Optionally, you can use Preset's table preview functionality to select the relevant tables and understand what data is stored.
Asking a question
Once the right database and schema are selected, you can start asking questions.
Here, you'll see the new AI Assist text box, where you can input a line of natural:
When finished, choose one of the following commands
|Command||What it does|
|Append (default)||The SQL query is appended in the SQL Editor.|
|Append and Run||The SQL query is appended, auto-selected, and executed.|
|Overwrite||The new query overwrites anything in the SQL Editor.|
|Overwrite and Run||The new query overwrites anything in the SQL Editor and automatically executes the new query.|