{"record":{"id":"160198d7b3a29cdc","repo":"vitessio/vitess","slug":"vt09015-160198","errorCode":"VT09015","errorMessage":"VT09015","messagePattern":"VT09015","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtgate/planbuilder/operators/horizon.go","lineNumber":165,"sourceCode":"\t\tif ctx.SemTable.EqualsExprWithDeps(col, f(column)) {\n\t\t\treturn offset, true\n\t\t}\n\t}\n\n\treturn\n}\n\nfunc (h *Horizon) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int {\n\tif underRoute && h.IsDerived() {\n\t\t// We don't want to use columns on this operator if it's a derived table under a route.\n\t\t// In this case, we need to add a Projection on top of this operator to make the column available\n\t\treturn -1\n\t}\n\n\tfor idx, se := range getFirstSelect(h.Query).GetColumns() {\n\t\tae, ok := se.(*sqlparser.AliasedExpr)\n\t\tif !ok {\n\t\t\tpanic(vterrors.VT09015())\n\t\t}\n\t\tif ctx.SemTable.EqualsExprWithDeps(ae.Expr, expr) {\n\t\t\treturn idx\n\t\t}\n\t}\n\n\treturn -1\n}\n\nfunc (h *Horizon) GetColumns(ctx *plancontext.PlanningContext) (exprs []*sqlparser.AliasedExpr) {\n\tfor _, expr := range ctx.SemTable.SelectExprs(h.Query) {\n\t\tae, ok := expr.(*sqlparser.AliasedExpr)\n\t\tif !ok {\n\t\t\tpanic(vterrors.VT09015())\n\t\t}\n\t\texprs = append(exprs, ae)\n\t}\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtgate/planbuilder/operators/horizon.go#L147-L183","documentation":"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.","triggerScenarios":"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.","commonSituations":"Planner stages running before star expansion completed; queries with SELECT * in derived tables hitting a code path that assumes expanded columns.","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"],"exampleFix":"-- before\nSELECT * FROM (SELECT * FROM tbl) t ORDER BY a\n-- after\nSELECT a FROM (SELECT a FROM tbl) t ORDER BY a","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func allAliasedExprs(stmt sqlparser.TableStatement) bool {\n    for _, se := range getFirstSelect(stmt).GetColumns() {\n        if _, ok := se.(*sqlparser.AliasedExpr); !ok { return false }\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["planner","vt09015","star-expansion","unsupported"],"backgroundTag":"unsupported-sql-feature","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}