AI Assisted SQL Querying
  • 05 Mar 2024
  • 3 Minutes to read
  • Dark
    Light

AI Assisted SQL Querying

  • Dark
    Light

Article Summary

The feature is available on the Professional & Enterprise plans.

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.

Overview

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.

Supported Databases

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

Feature enablement requires Team Admin permissions

👤 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

image.png

Navigate to the AI Assist tab and check the box to turn on AI Assist.

image.png

Data shared with OpenAI

AI Assist shares the following information from your database with OpenAI

  • Schema name
  • Table names
  • Table comments
  • Table relationships
  • Column names
  • Column types
  • Column comments
  • (Only if sample data / column-level statistics is enabled) A subset of 100 sample rows for each table

OpenAI does not use any of the data being shared via API for model training purposes. Please refer to the OpenAI Data Retention policies for more information.

You will also need to agree to the User Agreement to enable the feature.

Optional settings

Enable sample data / column-level statistics - Optional
Preset provides the ability to for users to share sample data back to OpenAI as context for more precise results. If enabled, a subset of 100 sample rows of data for each table will be shared, improving results.

image.png

Extra configurations - Optional
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.

image.png

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

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.
image.png

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 language:

image.png

When finished, choose one of the following commands

CommandWhat it does
Append (default)The SQL query is appended in the SQL Editor.
Append and RunThe SQL query is appended, auto-selected, and executed.
OverwriteThe new query overwrites anything in the SQL Editor.
Overwrite and RunThe new query overwrites anything in the SQL Editor and automatically executes the new query.

AI in BI demo copy.gif

Turning Results into Chart

Once your results are ready, you can save the query as a virtual dataset to be used in multiple charts, or go straigh to adding this output as a chart on your dashboard


Was this article helpful?