Description
The semantic request supports metrics, dimensions, filters, time grain, and limit, but it cannot order results by a requested metric.
For example, “Which account has the highest current ARR?” currently orders by the account dimension and may return the alphabetically first account instead of the account with the highest ARR.
Proposed solution
Add an orderBy field that:
- References only requested certified metrics or dimensions.
- Supports asc and desc.
- Rejects raw SQL expressions.
- Adds a stable dimension tie-breaker for deterministic Top-N results.
- Applies ordering before LIMIT.
{
"metrics": ["current_annual_recurring_revenue"],
"dimensions": ["account.account_name"],
"orderBy": [
{
"field": "current_annual_recurring_revenue",
"direction": "desc"
},
{
"field": "account.account_name",
"direction": "asc"
}
],
"limit": 1
}
Implementation areas
- internal/planner/plan.go
- internal/planner/plan_sql.go
- internal/serving/mcp/mcp.go
Planner, MCP, REST, StarRocks, and Trino tests
Description
The semantic request supports metrics, dimensions, filters, time grain, and limit, but it cannot order results by a requested metric.
For example, “Which account has the highest current ARR?” currently orders by the account dimension and may return the alphabetically first account instead of the account with the highest ARR.
Proposed solution
Add an orderBy field that:
{ "metrics": ["current_annual_recurring_revenue"], "dimensions": ["account.account_name"], "orderBy": [ { "field": "current_annual_recurring_revenue", "direction": "desc" }, { "field": "account.account_name", "direction": "asc" } ], "limit": 1 }Implementation areas
Planner, MCP, REST, StarRocks, and Trino tests