vitessio/vitess · error
VT09015
VT09015
Error message
VT09015
What it means
Horizon.FindCol iterates the first SELECT's column list expecting every select expression to be *sqlparser.AliasedExpr. Any other SelectExpr kind (e.g. a star expression that wasn't expanded) triggers VT09015, which signals the query contains something the planner does not support.
Source
Thrown at go/vt/vtgate/planbuilder/operators/horizon.go:165
if ctx.SemTable.EqualsExprWithDeps(col, f(column)) {
return offset, true
}
}
return
}
func (h *Horizon) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int {
if underRoute && h.IsDerived() {
// We don't want to use columns on this operator if it's a derived table under a route.
// In this case, we need to add a Projection on top of this operator to make the column available
return -1
}
for idx, se := range getFirstSelect(h.Query).GetColumns() {
ae, ok := se.(*sqlparser.AliasedExpr)
if !ok {
panic(vterrors.VT09015())
}
if ctx.SemTable.EqualsExprWithDeps(ae.Expr, expr) {
return idx
}
}
return -1
}
func (h *Horizon) GetColumns(ctx *plancontext.PlanningContext) (exprs []*sqlparser.AliasedExpr) {
for _, expr := range ctx.SemTable.SelectExprs(h.Query) {
ae, ok := expr.(*sqlparser.AliasedExpr)
if !ok {
panic(vterrors.VT09015())
}
exprs = append(exprs, ae)
}
View on GitHub (pinned to 01a25a7d17)
Solutions
- Ensure star expressions are expanded (semantics 'expandStar') before horizon column matching runs
- Rewrite the query to use explicit column lists instead of SELECT *
- If reproducible, file a Vitess bug — VT09015 marks an unsupported query feature
Example fix
-- before SELECT * FROM (SELECT * FROM tbl) t ORDER BY a -- after SELECT a FROM (SELECT a FROM tbl) t ORDER BY a
Defensive patterns
Strategy: type-guard
Type guard
func allAliasedExprs(stmt sqlparser.TableStatement) bool {
for _, se := range getFirstSelect(stmt).GetColumns() {
if _, ok := se.(*sqlparser.AliasedExpr); !ok { return false }
}
return true
} Prevention
- Ensure star expansion completes before column matching
- Use explicit column lists in derived tables
- Add planner assertions that select lists are expanded before horizon planning
When it happens
Trigger: Calling FindCol (directly or via AddColumn) on a horizon whose first SELECT still contains non-AliasedExpr select items, such as unexpanded '*' or qualified star expressions.
Common situations: Planner stages running before star expansion completed; queries with SELECT * in derived tables hitting a code path that assumes expanded columns.
Related errors
- VT13001
- query not supported by vexec
- Not implemented, post_header_length!=8
- Not implemented, post_header_length==6
- VT09015
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/160198d7b3a29cdc.
Report an issue: GitHub.