Skip to content
Middle+0 viewsAsked at 2 companies

You said you built an AI agent to automate impact analysis of SQL changes. Could you tell me more about it?

Practice

AI answer

The goal of such an agent is to determine, from a changed SQL statement, which objects and reports might be affected and to explain the chain of impact. For example, if a column in a table changes, the agent should find the queries, views, or data models that depend on it.

A practical architecture combines deterministic analysis and an LLM:

  1. It receives the SQL diff and repository context: dialect, object catalog, schemas, configuration, and, if available, a lineage graph.
  2. A parser builds an AST and extracts changed tables, columns, expressions, and dependencies. It is better to use a SQL parser for this than to ask an LLM to guess the structure from text.
  3. A dependency graph helps trace from changed objects to downstream views, models, and consumers. The agent ranks the findings by likelihood and severity of impact.
  4. The LLM produces an understandable summary: what changed, which consumers are affected, why, and what checks should be performed. Where possible, the output includes links to specific SQL lines and graph nodes.
  5. The result is checked with tests or static rules and passed to a human for review; the agent should not automatically treat its output as complete or safe to apply.

Key limitations include dynamic SQL, SELECT *, stored procedures, UDFs, an incomplete catalog, and dialect differences. These should be explicitly identified as areas of uncertainty. Quality can be measured on labeled changes by the completeness of the dependencies found, the precision of warnings, and the proportion of important consumers missed.