[Enhancement]: Let aggregate_records (MCP) compute multiple aggregations in one call (single GROUP BY pass)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 58/100
調査の方向性
MCP AggregateRecordsTool の引数解析から開始し、既存の GraphQL パスを含めて、GroupByMetadata.Aggregations と BaseTSqlQueryBuilder.BuildAggregationColumns を追跡します。function と field を保持したままオプションの aggregations 配列をサポートし、グループ化された結果が orderby と having で使用可能なエイリアスを持つ 1 つのクエリを生成することを検証します。
索引モデルが 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時間
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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時間 初心者へのやさしさ 82/100
NethermindEth/nethermind#14012 ·
メンテナーはふだん 1 日以内に返信
-
dependencies Status: Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
json-schema-org/website#2518 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
builtbybel/Flyoobe#498 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
builtbybel/CrapFixer#112 ·