vitessio/vitess · error
VT13001
VT13001
Error message
tried to add group by to a table
What it means
Internal planbuilder error: an attempt was made to add a GROUP BY to an operator representing a plain table, which does not support grouping. Thrown at go/vt/vtgate/planbuilder/operators/vindex.go:66.
Source
Thrown at go/vt/vtgate/planbuilder/operators/vindex.go:66
}
)
const wrongWhereCond = "WHERE clause for vindex function must be of the form id = <val> or id in(<val>,...)"
// Introduces implements the Operator interface
func (v *Vindex) introducesTableID() semantics.TableSet {
return v.Solved
}
// Clone implements the Operator interface
func (v *Vindex) Clone([]Operator) Operator {
clone := *v
return &clone
}
func (v *Vindex) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ae *sqlparser.AliasedExpr) int {
if gb {
panic(vterrors.VT13001("tried to add group by to a table"))
}
if reuse {
offset := v.FindCol(ctx, ae.Expr, true)
if offset > -1 {
return offset
}
}
return addColumn(ctx, v, ae.Expr)
}
func (*Vindex) AddWSColumn(*plancontext.PlanningContext, int, bool) int {
panic(vterrors.VT13001("did not expect this method to be called"))
}
func colNameToExpr(c *sqlparser.ColName) *sqlparser.AliasedExpr {
return &sqlparser.AliasedExpr{
Expr: c,View on GitHub (pinned to 01a25a7d17)
Solutions
- File a Vitess bug with the offending query and schema
- Simplify the query (avoid GROUP BY over the vindex-derived projection) as a workaround
- Update to the latest Vitess release where the planner path may be fixed
Defensive patterns
Strategy: try-catch
Try / catch
// internal invariant violation; guard with recover and report
defer func() {
if r := recover(); r != nil {
log.Printf("VT13001 planner panic: %v (query=%s)", r, query)
}
}() Prevention
- Report the triggering query upstream as a planner bug
- Upgrade to the latest Vitess patch release
- Avoid unusual GROUP BY shapes over vindex-routed single-table plans until fixed
When it happens
Trigger: pushProjectionInVindex calls Vindex.AddColumn with gb=true (group-by requested) on a Vindex operator — a planner bug scenario, not something a query can legitimately request.
Common situations: Internal planner edge case; queries combining vindex-only routing with GROUP BY that expose an unhandled path; typically a Vitess bug.
Related errors
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/af7ebc02a88f9ac9.
Report an issue: GitHub.