GitHub user allenjiji added a comment to the discussion: Agent using MCP cannot 
properly compute metrics

The agent invents a "count" column because it is being asked to write the 
aggregation itself. One way around this is to let it pick field names only and 
have a planner generate the SQL. That is what 0sql does (disclosure: I work on 
it).

The agent sends:

```json
{
  "projections": [
    { "field": "category" },
    { "field": "row count" }
  ]
}
```

And gets back:

```sql
SELECT T0.category AS "Category",
       count(*) AS "Row Count"
FROM orders T0
GROUP BY T0.category
```

"Row count" is defined once in the model as count(*), so the agent never needs 
to know how it is implemented. If it asks for a field that doesn't exist, it 
gets a refusal with the nearest valid fields instead of SQL containing a 
made-up column.

For Superset, you would put the returned SQL into a virtual dataset or SQL Lab 
rather than the chart API.

Its free to use: https://0sql.io/

GitHub link: 
https://github.com/apache/superset/discussions/40920#discussioncomment-18947509

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to