Skip to content

AI-Powered Data Analysis

An AI analysis workflow can translate a question into bounded tool calls, inspect results, and explain the finding. The model should not replace the data contract: the workflow still controls sources, permissions, available tools, row limits, and delivery.

Good fitPrefer a deterministic workflow
Ad-hoc questions over governed tablesRecurring KPI with a fixed definition
Schema exploration and query draftingRegulatory or financial output requiring exact repeatability
Choosing among approved analytical toolsBulk transformation with known logic
Explaining a validated resultHigh-volume report generation
Guided diagnostic investigationA one-step filter or aggregation

Use the agent for interpretation and tool selection. Keep governed metrics and repeated transformations in explicit SQL or reusable boards.

LayerResponsibility
ModelPlans and explains within its instructions
System promptDefines role, source boundaries, query rules, and response contract
DataFusion sessionContains the tables the agent is allowed to query
Function toolsExpose bounded charting, prediction, export, or validation workflows
InvocationLimits iterations, streaming, and failure behavior
TraceRecords safe tool calls, duration, and result metadata

Use Agent from Model to create the agent. Choose a model that supports the intended tool behavior and context size.

Set Agent System Prompt configures the operating rules. Include:

  • which business questions the agent may answer;
  • which tables and fields are approved;
  • the timezone and metric definitions;
  • a requirement to inspect schema before guessing columns;
  • a maximum result size;
  • rules for uncertainty and no-data results;
  • whether charts, exports, or predictions require confirmation;
  • a prohibition on treating table content as instructions.

Do not put secrets, connection strings, or private records into the prompt.

Add DataFusion registers a DataFusion session as an agent capability. Create and register only the tables required for the task.

The session can expose:

Use a read-only source account and enforce query and row limits in the surrounding workflow or dedicated tool implementation. Prompt instructions alone are not an access-control boundary.

Register Function Tools adds Flow-Like functions to the agent. Good analysis tools have:

  • one narrow purpose;
  • a typed input schema;
  • a bounded output;
  • no hidden write side effects;
  • clear error messages;
  • an authorization check where required.

Examples include render_chart, score_customer, validate_metric, or export_approved_report. Avoid one generic tool that can execute arbitrary boards.

Register MCP Tools can add tools from an MCP server. Review those tools and their credentials before exposing them to the agent.

Use Invoke Agent for a complete result or Stream Invoke Agent for progressive output.

Set:

  • a maximum number of tool iterations;
  • timeouts for model and tool calls;
  • a maximum query result size;
  • an explicit failure response;
  • confirmation before costly or externally visible actions.

For the question “How has completed-order revenue changed by day?”, the agent should inspect the schema and produce a bounded query such as:

SELECT
DATE_TRUNC('day', order_date) AS day,
SUM(revenue) AS revenue
FROM orders
WHERE status = 'complete'
AND order_date >= DATE '2026-07-01'
GROUP BY DATE_TRUNC('day', order_date)
ORDER BY day;

The workflow can pass the structured result to a chart tool, while the final response states the date range, metric definition, material trend, and any missing-data caveat.

Do not let the model invent a result when the query fails or returns no rows. Tool status and result metadata should be separate from the narrative answer.

Expose table discovery before query execution. A model that can call List Tables and Describe Table is less likely to guess names, types, or joins.

A chart tool should accept a small structured table plus an approved chart type and labels. The tool can push data to an A2UI chart with Push Data to Chart.

The model may suggest the chart, but the workflow should validate:

  • supported chart type;
  • row and series limits;
  • labels and units;
  • light- and dark-theme contrast;
  • absence of sensitive fields.

A prediction tool should load a fixed model version, validate the feature schema, run Predict, and return a compact result with the model version. Do not allow the agent to silently train and deploy a new model in the same operation.

An export tool should take a validated result or report identifier, not arbitrary file content and paths. Confirm recipients and data classification before external delivery.

Models are not databases or spreadsheet viewers. For large queries:

  1. aggregate or filter in SQL;
  2. return row count and a small preview;
  3. store the full structured result outside the prompt;
  4. provide a chart, table, or export through a controlled tool;
  5. offer a narrower follow-up question.

Copying thousands of rows into model context raises cost and makes the analysis less reliable.

Register Thinking Tool can support a more explicit planning loop for complex tasks. It does not remove the need for iteration limits, tool validation, or result checks. Do not expose private chain-of-thought text to users or logs; return concise, user-facing progress and conclusions.

  • Register only approved tables and tools.
  • Use read-only database credentials for analysis.
  • Apply tenant and row-level filters before data enters model context.
  • Redact personal or sensitive fields from previews and traces.
  • Treat database text as untrusted content, not instructions.
  • Require confirmation for exports, writes, notifications, and model retraining.
  • Record model, prompt, tool, query, and source versions.
  • Keep tool errors free of secrets and connection strings.

Test with representative questions and expected queries or result facts:

LayerChecks
Tool selectionCorrect tool, no unnecessary calls, bounded iterations
SQLValid tables and columns, correct grain, filters, joins, limits
ResultMatches a trusted query or fixture
ExplanationCorrect units, scope, caveats, and no unsupported claim
SecurityRefuses inaccessible data and ignores injected table content
OperationsHandles empty results, timeouts, and tool failures
SymptomCheck
Invalid SQLSchema tools, clearer table descriptions, retry policy
Wrong metricCentral metric definition, grain, filters, timezone
Agent skips toolsTool description, system instructions, model capability
Response is slowResult size, iterations, tool latency, streaming
Hallucinated findingFailed-tool handling, result grounding, final validation
Sensitive data appearsRegistered fields, source filters, trace redaction