Generate and fix SQL with AI

Generate SQL with AI writes a query for you in the Query step of a transformation or a View. Use it to start from a plain description, to change a query you already have, or to fix one that failed validation.

Draft a query with AI

Open the Query step of a transformation or a View and click AI in the editor header. The tooltip reads "Generate with AI". The window that opens, Generate SQL with AI, has the tables on the left and your prompt on the right.

  1. Click Select Tables and tick the tables the AI should use. They are grouped as Lake Tables and DWH Tables, each with a count. Until you pick some, the panel reads No tables selected.
  2. Choose what the AI should do. If the editor already has a query, pick Create new to write a fresh one or Modify to change the current one. For a query that is still empty, this choice does not appear.
  3. Describe what you need in the prompt panel, headed Describe your query. Write in your own words, or click the microphone and dictate; the Speech Language picker sets what dictation listens for. The box suggests an example: "e.g. Join orders with customers, show total revenue by country for last 30 days...".
  4. Click Generate. While the request runs, the window shows AI is creating your SQL query, the button reads Generating..., and the window cannot be closed. An empty prompt blocks the request with Prompt is required.
  5. When the result arrives, review it before anything is applied, as described below. If the request fails, the message reads Failed to generate with AI; try again.
Note

Your choices are remembered when you reopen the window: the table selection, the Create new or Modify choice, and your prompt.

Review and apply the suggestion

When the editor already has a query, the result opens in Query Difference Checker, which shows Current Query next to AI Suggested Query. Nothing changes until you decide:

If the editor has no query yet, the suggestion is placed in the editor directly and marked Not validated.

Fix a query that failed validation

When a query fails validation, the Query Validation Error window opens with the details.

  1. Read Error Details:.
  2. Optionally, add a note under Additional Context (optional) describing what you were trying to do.
  3. Click Fix with AI. The button reads Fixing... while the AI works, and the window cannot be closed until it finishes.
  4. The corrected query opens in Query Difference Checker, the same review window as above. Apply it, then validate the query again.

You can also close the window and fix the query yourself.

Questions, answered

Where do I find the AI that writes the query?

Open the Query step of a transformation or a View and click AI in the editor header. Its tooltip reads "Generate with AI". The editor itself is described on Write and validate a transformation query and Write and validate a View query.

Why is Generate disabled?

The button is disabled while the AI is busy or the prompt box is empty. Write what the query should do, then try again.

What happens to the query I already have?

Nothing until you apply. Query Difference Checker shows your Current Query and the AI Suggested Query side by side: Apply Changes replaces your query, and Close keeps it as it is.

Can I dictate the prompt instead of typing?

Yes. Click the microphone and speak; your words appear over the prompt box while you talk and are added to the prompt when you stop. The Speech Language picker sets the language dictation listens for.

Why can't I close the window while it is generating?

While a request is in flight, the close button and the area around the window are disabled. Wait for it to finish; the result opens for review.

Which tables does the AI work from?

The ones you tick in Select Tables. They are grouped as Lake Tables and DWH Tables; pick the tables your query should read before you generate.

Does generating touch my dependencies?

The tables you pick are saved as the dependencies of the transformation or the View. Warehouse tables are saved together with their source systems, so the dependencies you set with Manage Dependencies are not lost. Check the Dependencies step after you apply.

The generated query failed to validate. What now?

The Query Validation Error window opens with the details. Read Error Details:, optionally add Additional Context (optional), and click Fix with AI for a corrected query; review it in Query Difference Checker and apply it. You can also close the window and fix the query yourself.