[Enhancement]: Let aggregate_records (MCP) compute multiple aggregations in one call (single GROUP BY pass)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 MCP AggregateRecordsTool 的参数解析开始,然后跟踪 GroupByMetadata.Aggregations 和 BaseTSqlQueryBuilder.BuildAggregationColumns,包括现有的 GraphQL 路径。支持可选的 aggregations 数组,同时保留 function 和 field,并验证分组结果会生成一个带有可供 orderby 和 having 使用的别名的查询。
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem?
The MCP aggregate_records tool accepts only one aggregate per call (function + field). To retrieve several metrics over the same grouping, a client must issue N separate calls, each generating its own query with the same GROUP BY:
SELECT region, SUM(amount) FROM dbo.Sales WHERE ... GROUP BY region
SELECT region, AVG(amount) FROM dbo.Sales WHERE ... GROUP BY region
SELECT region, SUM(cost) FROM dbo.Sales WHERE ... GROUP BY region
This scans the same rows and recomputes the same GROUP BY N times, plus N× query-planning / result-shaping / round-trip overhead. On large tables/views this is a real, avoidable database cost. Issuing the N calls concurrently on the client side only reduces latency — it does not reduce total DB work and can increase peak load/contention.
Describe the solution you'd like
Allow aggregate_records to accept multiple aggregations in a single call, producing one SELECT with one GROUP BY pass, e.g.:
{
"entity": "Sales",
"aggregations": [
{ "function": "sum", "field": "amount", "alias": "sum_amount" },
{ "function": "avg", "field": "amount", "alias": "avg_amount" },
{ "function": "sum", "field": "cost", "alias": "sum_cost" }
],
"groupby": ["region"],
"orderby": ["sum_amount desc"]
}
which maps to a single query:
SELECT region, SUM(amount) AS sum_amount, AVG(amount) AS avg_amount, SUM(cost) AS sum_cost
FROM dbo.Sales
WHERE ...
GROUP BY region
orderby/having should be able to reference the aggregate aliases (e.g. sum_amount), consistent with how grouped results are projected.
Why this looks feasible
DAB already builds multi-aggregation queries internally for GraphQL: the shared SqlQueryStructure.GroupByMetadata.Aggregations is a List<AggregationOperation> and BaseTSqlQueryBuilder.BuildAggregationColumns(...) emits all requested aggregate expressions into a single SELECT. The MCP aggregate_records tool (AggregateRecordsTool) currently parses and loads only a single AggregationOperation. Extending its argument parsing to accept an array and pushing multiple AggregationOperations onto the existing structure would reuse the machinery GraphQL already relies on.
Backward compatibility
Keep the current single-metric form (function + field) working as-is; add the new optional aggregations array alongside it. Single-metric callers are unaffected; multi-metric callers opt in.
Additional context
- Related: #3695 (a separate correctness bug in the aggregate
ORDER BYfordwsql). This enhancement is independent of that fix. - Benefit is largest for wide analytical tables/views where several measures are aggregated over the same grouping in one logical request.
- 主要语言
- C#
- 星标
- 1.5k
- 派生
- 371
- 平均合并
- 7 天 5 小时
- 30 天内合并 PR
- 8
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/data-api-builder 的其他 Issue
-
pgsql
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3598 ·
维护者通常 1 天内回复
-
2.x cli mcp-server
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3576 ·
维护者通常 1 天内回复
-
2.x health-endpoint
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3570 ·
维护者通常 1 天内回复
-
2.x telemetry
难度 2/5 1-3 小时 新手友好度 68/100
Azure/data-api-builder#3564 ·
维护者通常 1 天内回复
-
2.x telemetry
难度 2/5 1-3 小时 新手友好度 70/100
Azure/data-api-builder#3562 ·
维护者通常 1 天内回复
查看 Azure/data-api-builder 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
builtbybel/CrapFixer#112 ·
-
area-ai untriaged
难度 2/5 1-3 小时 新手友好度 85/100
dotnet/extensions#7790 ·
维护者通常 1 天内回复
-
Beginner Friendly T: Bugfix
难度 2/5 1-3 小时 新手友好度 82/100
space-wizards/space-station-14#46220 ·
维护者通常 1 天内回复
-
P2 testing
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
area-Infrastructure-coreclr os-ios os-maccatalyst os-tvos untriaged
难度 2/5 1-3 小时 新手友好度 78/100
dotnet/runtime#134766 · 3 条评论 ·
维护者通常 1 天内回复