vitessio/vitess · error
invalid expression: %v
Error message
invalid expression: %v
What it means
analyzeExpr requires every select expression to be either a plain *sqlparser.AliasedExpr column/aliased expression. Any other SelectExpr kind (e.g. a star expression `*` or `t.*`) cannot be converted into an explicit column plan and triggers this error.
Source
Thrown at go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go:432
}
return sel, fromTable.String(), nil
}
func (tpb *tablePlanBuilder) analyzeExprs(selExprs []sqlparser.SelectExpr) error {
for _, selExpr := range selExprs {
cexpr, err := tpb.analyzeExpr(selExpr)
if err != nil {
return err
}
tpb.colExprs = append(tpb.colExprs, cexpr)
}
return nil
}
func (tpb *tablePlanBuilder) analyzeExpr(selExpr sqlparser.SelectExpr) (*colExpr, error) {
aliased, ok := selExpr.(*sqlparser.AliasedExpr)
if !ok {
return nil, fmt.Errorf("invalid expression: %v", sqlparser.String(selExpr))
}
as := aliased.As
if as.IsEmpty() {
// Require all non-trivial expressions to have an alias.
if colAs, ok := aliased.Expr.(*sqlparser.ColName); ok && colAs.Qualifier.IsEmpty() {
as = colAs.Name
} else {
return nil, fmt.Errorf("expression needs an alias: %v", sqlparser.String(aliased))
}
}
cexpr := &colExpr{
colName: as,
references: make(map[string]bool),
}
if expr, ok := aliased.Expr.(*sqlparser.ConvertUsingExpr); ok {
// Here we find the actual column name in the convert, in case
// this is a column rename and the AS is the new column.
// For example, in convert(c1 using utf8mb4) as c2, we want to findView on GitHub (pinned to 01a25a7d17)
Solutions
- Enumerate columns explicitly in the select list instead of using *
- Regenerate the plan after adding new columns so the explicit list stays current
- Use the keyspace_id() function or plain column names supported by the plan builder
Example fix
// before SELECT * FROM t // after SELECT id, name, keyspace_id() as keyspace_id FROM t
Defensive patterns
Strategy: validation
Validate before calling
for _, e := range sel.SelectExprs {
if _, ok := e.(*sqlparser.AliasedExpr); !ok {
return fmt.Errorf("select list must be explicit columns/aliased exprs; got %T", e)
}
} Type guard
func allAliasedExprs(exprs []sqlparser.SelectExpr) bool {
for _, e := range exprs {
if _, ok := e.(*sqlparser.AliasedExpr); !ok { return false }
}
return true
} Try / catch
plan, err := buildReplicatorPlan(...)
if err != nil && strings.Contains(err.Error(), "invalid expression") {
// rewrite select list without star expressions and retry
} Prevention
- Never use SELECT * in filter rules; enumerate columns
- Regenerate rules after schema changes
- Preflight-parse filter select lists
When it happens
Trigger: A filter select list contains `SELECT *` or `table.*` (StarExpr) instead of explicitly enumerated columns.
Common situations: Users writing MoveTables filter rules with `SELECT *`; code generators emitting star selects; schema changes that encouraged wildcard selects.
Related errors
- expression needs an alias: %v
- failed to find column name for convert using expression: %v,
- table %s not found in schema
- more than one target for source table %s: %s and %s
- unsupported from expression (%T)
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/dc6b01bf97689157.
Report an issue: GitHub.