ReadingResearchRadarInvestment framework
Sign in / Sign up
← Back to reading
NewsTopic · NL2SQL Agent EvaluationMaterial4 min readDisconfirmAI Editorial

A Deterministic SQL Evaluator for NL2SQL Agents: Handling Aliases, Permutations and Superset Columns in ADK

Google Cloud AI engineer Rupjit Chakraborty identifies five scenarios where exact string match and naive table diff produce false negatives on semantically correct NL2SQL queries, then walks through a six-step Python normalization pipeline—value casting, column alignment by frequency counters, superset filtering, one-to-one mapping, order-invariant row hashing and equality verdict—that resolves all five at zero LLM token cost, paired with built-in trajectory scoring and a rubric-based judge for a three-layer evaluation.

2026-12-01

The evaluator's dilemma in NL2SQL is concrete: an agent writes a query that returns the exact business answer a user needs, yet fails every standard check because it aliased a column, reordered the SELECT clause, returned rows in a different sequence, cast a price to a different precision, or included a helpful context column the gold standard omitted.

Rupjit Chakraborty, an AI engineer at Google Cloud, documents this mismatch in a December 2026 post on designing custom evaluation metrics in the Agent Development Kit. The built-in criteria—tool_trajectory_avg_score, which checks for exact match on tool arguments including the raw SQL string, and response_match_score, which measures word overlap via ROUGE-1—penalize valid variations rather than catching genuine errors.

The five failure modes are well-illustrated. First, the alias problem: a gold query returns a column named prod_sale_rev_fy25 while the agent presents it as "Revenue FY2025"—same data, different header, exact match fails. Second, the permutation problem: the agent selects email, last_login, user_id instead of user_id, email, last_login—same records, different column order, naive table diff fails. Third, the sorting problem: distributed warehouses like BigQuery do not guarantee row order without an explicit ORDER BY, so two identical queries can return rows in different sequences. Fourth, the data-type problem: a gold query casts price to DECIMAL(10,2) yielding 99.50 while the agent returns the raw numeric 99.5—mathematically equal, string-unequal. Fifth, the superset problem: a user asks for active project names, the agent also returns project_lead and due_date as helpful context, and the evaluator rejects the result for having three columns instead of one.

Sign in / Sign up
ReadingResearchRadarInvestment framework

Chakraborty's solution is a six-step deterministic pipeline implemented as a custom Python metric registered through ADK's custom_metrics field. Step one normalizes values: integers, floats, Decimal objects and numeric strings become rounded floats; dates become ISO-8601 strings; text is trimmed. Step two computes a collections.Counter of normalized values for each column, then matches gold columns only against predicted columns sharing identical value distributions—this neutralizes aliases and reduces combinatorial explosion on wide tables. Step three applies superset filtering: when allow_superset is True, the evaluator requires at least as many predicted columns as gold columns and ignores extras. Step four identifies a valid one-to-one mapping between every gold column and a distinct predicted candidate. Step five projects predicted rows through that mapping and compares them as unordered tuple counters, making the check invariant to row order. Step six returns a boolean verdict with the matched column mapping for debugging.

The method is embedded in a three-layer evaluation architecture. The first layer uses the built-in tool_trajectory_avg_score with match_type set to IN_ORDER and ignore_args set to true, verifying that the agent calls the right database tools in sequence without flagging SQL syntax variations as argument failures. The second layer is the custom deterministic metric described above, running at zero LLM token cost. The third layer uses ADK's rubric_based_final_response_quality_v1 criterion with a judge model to confirm that any extra context columns are genuinely helpful and that the agent's natural-language summary matches the returned data.

The approach works under specific conditions. It assumes the gold and predicted result sets have the same number of rows; if an agent's query returns a different row count, the evaluator flags a mismatch before reaching column alignment. It also assumes that value distributions are distinctive enough to disambiguate columns—if two unrelated columns happen to contain the same set of values with the same frequencies, the Counter-based alignment could match them incorrectly. The author acknowledges this by requiring the one-to-one mapping step to verify row-level tuple alignment across the full projected set, which catches most false column matches but adds computational cost proportional to the number of valid candidate mappings.

The superset handling is the most consequential design choice. By defaulting allow_superset to True, the deterministic layer never penalizes an agent for adding columns. The question of whether those extra columns are genuinely helpful or merely noise is deferred to the LLM-judge layer, which introduces non-determinism and token cost back into the evaluation. For teams that need a fully deterministic pass/fail signal, this means the custom metric alone cannot distinguish a helpful context column from an irrelevant one.

The implementation is wired through a standard eval_config.json that registers the metric by module path (nl2sql_custom_metric.semantic_sql_result_match) alongside the built-in criteria, and a test fixture file (nl2sql.evalset.json) that records each case's user prompt, expected tool call with gold-standard tool_responses rows, and reference natural-language answer. Running the suite requires only the adk eval CLI command with the agent module, fixture file and config path.

Sources

  • cloud.google.comGoogle Cloud Blog↗
Topic

NL2SQL Agent Evaluation

The evaluation of Natural Language to SQL (NL2SQL) agents is undergoing a critical shift from rigid string matching to s…

3 steps1 piecesUpdated 2026-12-01 19:31

How it got here

  1. 2026-12-01December 1, 2026: Google Cloud published a blog post detailing a custom deterministic evaluator for NL2SQL agents in ADK, addressing five common failure modes of exact string matching.cloud.google.com ↗
  2. 2026-07-02July 2, 2026: The paper 'ROSE: An Intent-Centered Evaluation Metric for NL2SQL' was presented at ACL 2026, proposing a new metric to overcome the limitations of Execution Accuracy.aclanthology.org ↗
  3. 2026-04-01April 2026: The preprint 'NL2SQLBench' was released, introducing a modular benchmarking framework that critiques current evaluation rules and datasets.arxiv.org ↗

What is still unsettled

  • How will the adoption of deterministic semantic evaluators impact the computational cost and latency of large-scale agent testing compared to LLM-as-a-judge methods?
  • Can intent-centered metrics like ROSE be effectively integrated into production CI/CD pipelines without requiring extensive human annotation for validation?
Read the full topic →
Continue researching →