Google Cloud Shows How to Score NL2SQL Agents Without Penalizing Valid SQL
Google Cloud published a method for testing SQL-writing data agents built on ADK. It replaces exact string and cell-by-cell table checks with a semantic comparison that ignores harmless differences in column names, order and types.

TL;DR
- Standard evaluation checks for NL2SQL agents often mark correct answers as failures, because they compare SQL text and table layout exactly.
- Google Cloud's approach compares what a query returns, using a custom Python metric in Google's Agent Development Kit (ADK) with a rubric-based judge alongside it.
- The metric tolerates aliased columns, reordered columns, shuffled rows, numeric formatting differences and extra context columns.
Why standard checks break on SQL
NL2SQL systems turn natural-language questions into SQL. Newer versions act as data agents: they inspect schemas, validate queries and summarize live results from warehouses such as BigQuery. Testing them is harder than testing a function with one correct output. In a post on the Google Cloud Blog, AI engineer Rupjit Chakraborty argues that the built-in ADK criteria often fall short. The tool_trajectory_avg_score criterion checks tool arguments, including the raw SQL string for exact match, and response_match_score measures word overlap using ROUGE-1. Both penalize valid variations in generated SQL.
The post names five cases where exact string matching or a naive cell-by-cell table diff produces false negatives:
- Aliases: the agent renames a cryptic column such as prod_sale_rev_fy25 to "Revenue FY2025".
- Column order: the same attributes come back in a different sequence.
- Row order: SQL does not guarantee row order unless the query has an ORDER BY clause, and distributed engines can return rows in different sequences.
- Types and precision: 99.50 and 99.5 are mathematically equal, but a raw comparison treats them as different.
- Superset columns: the agent adds helpful context columns, such as a project lead or a due date, and a strict diff rejects the extra data.
A three-layer evaluation
The proposed setup combines built-in and custom metrics across three layers. Trajectory evaluation uses the built-in tool_trajectory_avg_score with match_type set to IN_ORDER and ignore_args set to true, so the agent must call the right database tools in sequence without being judged on SQL syntax. The deterministic semantic check is a custom ADK metric that normalizes the gold result set and the predicted result set, then compares them at zero LLM token cost. The third layer is an LLM-as-a-judge check using the rubric_based_final_response_quality_v1 criterion, which asks whether extra columns are useful and whether the natural-language summary matches the returned data.
How the custom metric works
The semantic evaluator, SemanticSQLEvaluator, runs a six-step pipeline. First, it normalizes values: numbers, including Decimal objects and numeric strings, are cast to floats rounded to a fixed precision, dates and timestamps become ISO-8601 strings, and text whitespace is stripped. Second, each column becomes an unordered frequency counter built with Python's collections.Counter, and a gold column is only compared with predicted columns that have identical value counts. This neutralizes aliases and keeps comparisons manageable on wide tables. Third, when allow_superset is enabled, the predicted table must have at least as many columns as the gold table, and only the required gold columns are matched. Fourth, the evaluator looks for a one-to-one mapping between gold and predicted columns. Fifth, it projects predicted rows through that mapping and counts the resulting tuples, so row order does not matter. Finally, it returns a boolean verdict with the column mapping for debugging. The ADK wrapper turns that verdict into a pass or fail result.
The post also warns that leading-zero codes such as zip codes, and 64-bit integer IDs, should stay as strings. Converting them to floats would corrupt them. The metric is registered through the custom_metrics field in the ADK evaluation config, and the article recommends pairing it with realistic multi-row test fixtures so that a wrong query does not pass by coincidence.
Why it matters
For teams building text-to-SQL features, the main change is in how test suites are written. Exact-match assertions on generated SQL will produce noise and push engineers to over-constrain prompts. A result-based check with explicit rules for ordering is closer to what users care about: whether the data they receive is correct. Teams still need to decide where order matters, for example for ranked answers such as "top 5 customers", where the evaluator should enforce row order. They also need to keep the LLM judge for the parts a deterministic check cannot see, such as whether a summary is faithful to the data. Developers working on data agents on other platforms can apply the same ideas, since the principles are not tied to one framework. For background on building developer tooling around PostgreSQL queries, see our post on pgjumbo.
Sources
This article was written by Blozhik from the reporting below. Read the originals for full detail.
GoDesigning Custom Evaluation Metrics in ADK for NL2SQL Data AgentsGoogle Cloud Blog

