Search docs.molo17.com
    Operational guide Control Plane

    Write SQL with Spark, the AI helper in Query Studio

    Spark is the AI helper built into the Query Studio editor. Describe the data you need in plain words, and Spark reads the schema of the connection, drafts the SQL, and explains it. You review the draft, put it in the editor, and run it like any other query. This guide connects a model provider, asks Spark for a real query, and uses Tab completion while you type.

    In this guide

    You will learn how to connect an LLM provider from Query Studio, ask Spark for a query in plain words, review the draft and run it, complete a statement with Tab, and manage the providers in Settings → LLM providers.

    The steps were run on a PostgreSQL 16 source with an Anthropic model and with a local Ollama server.

    Quick information

    Goal

    Draft and run SQL from a plain-language question with Spark in Query Studio

    Audience

    Data engineers, analysts, and Gluesync administrators

    Level

    Basic

    Time required

    About 20 minutes

    Area

    Control Plane → Query Studio, and Settings → LLM providers

    Applies to

    Gluesync 2.3

    Before you begin

    Make sure that:

    1. A pipeline has a SQL-capable agent that you can open in Query Studio. The examples use a PostgreSQL source with the tables shop.customers, shop.orders, and shop.order_items;

    2. You can sign in to the Control Plane as a Super Admin to add the model provider;

    3. You have access to a model that supports tool calling: an API key for OpenAI, Anthropic, or Azure OpenAI, an OpenAI-compatible endpoint, or an Ollama server that Core Hub can reach;

    4. For a cloud provider, Core Hub can open outbound HTTPS connections to the provider’s API.

    Gluesync does not host a model. Spark sends your question, and the schema details it looks up, to the provider you configure. Choose a provider that your data policy allows. See AI models and LLM providers for each provider type and its network requirements.

    Guide steps

    Connect an LLM provider

    UI

    1. Sign in to the Control Plane as a Super Admin and open Query Studio;

    2. Select the round Spark launcher at the bottom right of the editor, if the panel Spark in Query Studio is not open yet;

    3. Select Connect an LLM provider.

    Query Studio with the Spark in Query Studio panel open over the editor
    Figure 1. Without a provider, Spark asks a Super Admin to connect one.

    The Add LLM provider dialog opens over Query Studio.

    The example connects Anthropic. The other provider types use the same dialog.

    1. In Name, enter a name for the provider, for example Anthropic;

    2. In Provider, choose Anthropic. The list also offers OpenAI, OpenAI compatible, Azure OpenAI, and Ollama;

    3. In Default model, type the model name, for example claude-sonnet-5, and press Enter, or pick it from the list;

    4. In API key, paste your Anthropic API key. The key is stored encrypted in Core Hub and is never shown again;

    5. Leave Base URL empty. The field shows the default endpoint https://api.anthropic.com/v1, and you change it only to go through a proxy;

    6. Select Add provider.

    Add LLM provider dialog with the name Anthropic
    Figure 2. The Add LLM provider dialog filled for Anthropic. The API key is masked.
    Expected result

    LLM provider added. appears. The panel subtitle changes to Describe the data you need and review the proposed SQL., and the panel offers sample questions such as Where can I find the customers data?

    Add provider stays disabled until the dialog has a name, a default model, and, for a cloud provider, an API key. If it stays disabled after you type a model name, select Default model and press Enter.

    Core Hub waits up to three minutes for each answer of the model. In the test for this guide, small models on a server without a GPU either did not answer in time or drafted SQL with table and column names that do not exist. Use a cloud model, or a local model on a host with a GPU. See Local models with Ollama for the hardware notes.

    Ask Spark for a query

    UI

    1. Start from an empty editor tab: select + (New query tab) next to the editor tabs;

    2. In the Spark panel, select the field Ask where data lives or describe a query…;

    3. Describe the result you want, for example Show the 10 customers with the highest total of paid orders, with their country;

    4. Select the send arrow;

    5. Wait while the panel shows Drafting SQL…;

    6. Select the expand icon in the panel header to read the whole answer.

    Expanded Spark in Query Studio conversation with the question
    Figure 3. Spark lists the tables and columns it found, explains its plan, and proposes the SQL.
    Expected result

    The answer names the tables it found, here shop.customers, shop.orders, and shop.order_items, explains how it computes the total, and ends with the proposed SQL and the buttons Replace query and Insert into editor. Tool activity lists the lookups Spark made, for example list_tables and describe_table, and the header of the expanded view counts them in View tool calls.

    Spark also reads the SQL that is already in the editor. When the editor holds a query, Spark reviews that query instead of writing a new one. Start a new query tab for a new question, and keep the query in the editor when you want Spark to check or change it.

    Review the draft and run it

    UI

    1. Read the proposed SQL. Check that the schema, table, and column names exist in the schema browser on the left, and that the filter matches what you asked;

    2. Select Insert into editor to add the SQL at the cursor, or Replace query to replace everything in the editor;

    3. Close the Spark panel with the launcher;

    4. Select Run.

    Query Studio editor with the inserted query and the result grid
    Figure 4. The draft runs like any other query. Columns that are classified as personal data stay masked.
    Expected result

    The status bar shows Completed and the number of rows, here 10 rows. Columns that Query Studio tags as personal data, here PII:name and PII:secret, show ••••. To see who may unmask them, follow Query pipeline data with Query Studio.

    If the draft is not right, ask a follow-up question in the same conversation, for example to change the filter or to add a column, or edit the SQL yourself. Select the bin icon (Clear conversation) in the panel header to start over.

    Complete a statement with Tab

    UI

    1. Open a new query tab;

    2. Type the start of a statement, for example SELECT c.country, COUNT(DISTINCT o.id) AS paid_orders, then press Enter;

    3. Type FROM shop.customers c and press Enter;

    4. Pause, and read the gray suggestion after the cursor;

    5. Press Tab to accept it.

    Query Studio editor with two typed lines
    Figure 5. Spark suggests the rest of the statement in gray, from the cursor on.
    Expected result

    The suggested lines become part of the statement. In the example, Spark added the join to shop.orders, the filter WHERE o.status = 'paid', and GROUP BY c.country. A suggestion can stop in the middle of a clause: finish the statement yourself before you run it.

    The gray suggestion appears when the regular autocomplete list of the editor is closed, for example at the start of a new line. While that list is open, Tab picks the selected entry of the list instead.

    Manage the providers

    UI

    1. Select the gear icon (Settings) in the top bar;

    2. Select LLM providers;

    3. On the Providers tab, read the list of providers.

    Expected result

    The list shows each provider with its Name, Provider, Default model, Credential (Configured for a saved API key, Not required for Ollama), Status, and the cost and tokens of this month. Estimated spend this month sums the cost of all model calls. Each row has the actions Disable provider, Edit provider, and Delete provider, and Add provider adds another one.

    A conversation keeps the provider it started with. After you disable or change a provider, select Clear conversation in the Spark panel before you ask again.

    What the Spark panel offers

    Control What it does

    Sample questions

    Scan this schema for hidden PII, Where can I find the customers data?, and Help me retrieve the latest orders with out-of-stock items. are offered until you ask your first question

    Expand icon

    Opens the conversation in a large view, with View tool calls in its header

    Bin icon (Clear conversation)

    Starts a new conversation

    Insert into editor

    Adds the proposed SQL at the cursor, without running it

    Replace query

    Replaces the content of the editor with the proposed SQL, without running it

    Never paste passwords, tokens, connection strings, or private keys into the chat; the panel reminds you of this above the question field.

    Verify the result

    You have used Spark in Query Studio if:

    • Settings → LLM providers lists your provider with the status Enabled;

    • Spark answered a question with a SQL draft that names tables of your connection;

    • the draft ran from the editor with the status Completed;

    • Tab accepted a gray suggestion in the editor.

    Troubleshooting

    Problem Possible cause What to do

    The panel shows Connect an LLM provider

    No model provider is configured

    As a Super Admin, select Connect an LLM provider and add one

    Add provider stays disabled

    A required field is empty, or a typed model name was not confirmed

    Fill Name and, for a cloud provider, API key; type the model in Default model and press Enter

    After about three minutes: Spark could not respond. Check your LLM provider or retry.

    The model did not answer in time, for example a local model on a server without a GPU

    Use a faster model, a cloud provider, or a host with a GPU, then select Retry

    Right after you ask: Spark could not respond. Check your LLM provider or retry.

    The conversation still uses a provider that was disabled or deleted

    Select Clear conversation and ask again

    The draft fails with ERROR: relation "customers" does not exist

    The draft has no schema name, or names a table or column that does not exist

    Check the names in the schema browser, then ask again with the schema name, for example shop.customers, or edit the SQL

    ERROR: relation "gluesync.ai" does not exist

    The query SELECT answer FROM gluesync.ai …​ shown in the panel ran on the database of the agent in Query Studio

    Run gluesync.ai queries from a JDBC client through Query Forge; see AI as SQL virtual catalog

    No gray suggestion appears while you type

    The autocomplete list of the editor is open

    Press Enter to start a new line, then pause

    Optional, for advanced users

    The Core Hub log names the cause of Spark could not respond: LLM provider request timed out. Try again, or use a faster model. for a slow model, and LLM provider '<id>' is disabled for a conversation that uses a disabled provider.

    Contact MOLO17 Support if you need assistance with Spark or Query Studio.