# Query Builder

### Overview:

Query Builder is Lumi AI's dedicated SQL development environment, enhanced with Lumi AI as a context-aware Copilot. It provides analysts with a code-first workspace to write, test, and iterate on SQL while leveraging AI assistance grounded in their organization’s Knowledge Base. This enables faster iteration, easier debugging, and more reliable insight generation.

### Key Capabilities/ Benefits :

* **Dedicated SQL Editor** – A full SQL development environment designed for analysts who want direct control over joins, filters, calculations, and query structure.
* **Contextual AI Copilot** – AI assistance that understands your schema, stored definitions, and business context to help extend or improve queries.
* **One-Click Debugging** – Automatically diagnose and resolve SQL errors with contextual suggestions surfaced directly in the editor.
* **Tracked Iterations** – Every query version is preserved, allowing analysts to experiment safely and revert to previous logic when needed.
* **Publishing to Boards** – Share validated queries directly to Boards to make insights visible across teams.
* **Alerts on Trusted Logic** – Configure alerts on queries so teams are automatically notified when important thresholds are reached.

***

## How to Use Query Builder

Step 1: Select the **"Query Builder"** feature on the left hand side of your navigation pane

<figure><img src="https://1092914297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbsNNtXffkOLYrtYRQIcx%2Fuploads%2FhGBkpLrCrHediGwrg2MF%2Fimage.png?alt=media&#x26;token=638d6730-0ec5-4ef0-85d2-55dcc95c7c32" alt=""><figcaption></figcaption></figure>

Step 2: Users can either click **"Start Code"** to begin writing SQL manually, or use the AI assistant to automatically generate a baseline query that they can review and modify.

<figure><img src="https://1092914297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbsNNtXffkOLYrtYRQIcx%2Fuploads%2FSBRfjmwKTkoFuRb7Hv8v%2Fimage.png?alt=media&#x26;token=5341a31f-d4ae-4f1d-93f0-d748e67cd4ff" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Below is an example of the SQL code generated by Lumi's AI CoPilot
{% endhint %}

<figure><img src="https://1092914297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbsNNtXffkOLYrtYRQIcx%2Fuploads%2F9ijfJMtWRbYL5TAkEz2R%2Fimage.png?alt=media&#x26;token=ddd0b5dd-b78e-4340-8348-f2673216e764" alt=""><figcaption></figcaption></figure>

Step 3: Edit the generated SQL in the SQL Editor to customize the query and further enrich the results displayed in your visualization.

<figure><img src="https://1092914297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbsNNtXffkOLYrtYRQIcx%2Fuploads%2FiN66EgNLwoyiq7qzvw1o%2Fimage.png?alt=media&#x26;token=c6b7ab24-8657-4a38-bcdb-239dda134d21" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If an error occurs, click **Debug** to automatically diagnose the issue and update your SQL query with the appropriate corrections.
{% endhint %}

<figure><img src="https://1092914297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbsNNtXffkOLYrtYRQIcx%2Fuploads%2FNFbZvLLGRq993EJ2Y68t%2Fimage.png?alt=media&#x26;token=ada2fd23-a9eb-4dcb-b1d2-77c455fc261b" alt=""><figcaption></figcaption></figure>

Step 4: Every update to your SQL query is automatically saved as a new iteration. Previous versions can be rerun or revisited, making it easier to track changes and maintain a reproduceable audit trail

<figure><img src="https://1092914297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbsNNtXffkOLYrtYRQIcx%2Fuploads%2FoJbErVt7c8XoYssUe5fW%2Fimage.png?alt=media&#x26;token=b0480624-890d-4b9a-b9ea-1459fe9e3b13" alt=""><figcaption></figcaption></figure>

Step 5: Once complete, you can publish the Board and share the insights with your team.

<figure><img src="https://1092914297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbsNNtXffkOLYrtYRQIcx%2Fuploads%2FKGKfuTuxQkpa2ubDtTNF%2Fimage.png?alt=media&#x26;token=c2008195-2e3c-441b-b26e-d1136dd373af" alt=""><figcaption></figcaption></figure>
