vitessio/vitess · error

only integer literals are supported

Error message

only integer literals are supported

What it means

The VReplication planbuilder's analyzeExpr only supports a very restricted WHERE-clause grammar; inside a *sqlparser.Literal case it requires the literal type to be sqlparser.IntVal. Any non-integer literal (string, float, hex) used in the filter's where expression yields "only integer literals are supported".

Solutions

  1. Rewrite the filter where clause to use only expressions the planbuilder supports (in/equality on columns, integer literals like 1).
  2. Replace string literals with supported constructs, e.g. use in: lists or keyrange-based filters instead of string comparisons.
  3. Filter on the column(s) directly rather than constant literals other than the supported 1.

Example fix

// before
filter := "{" "where": "col = 'value'" "}" // string literal unsupported
// after
filter := "{" "keyrange": "-80", "in_keyrange": true "}" // supported filter form
Defensive patterns

Strategy: validation

Validate before calling

// ensure filter where clause only uses supported expressions
// allowed: column comparisons / in() with integer literals; the only constant allowed is 1
if strings.Contains(whereClause, "'") { return errors.New("string literals are not supported in VReplication filter where") }

Type guard

func isIntLiteral(lit sqlparser.Literal) bool { return lit.Type == sqlparser.IntVal }

Try / catch

if err := startStream(...); err != nil && strings.Contains(err.Error(), "only integer literals are supported") {
  return fmt.Errorf("filter where clause invalid: %w", err)
}

Prevention

When it happens

Trigger: Writing a VReplication filter with a where clause containing a string or other non-integer literal, e.g. where: "col = 'abc'" or a float constant, in keyspace/table filters for VStream.

Common situations: Users configuring move-tables / resharding filters expecting full SQL where-clause support; copying an SQL WHERE into a VReplication filter's json where field.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/01c06b837eace332. Report an issue: GitHub.

Appendix: source

Thrown at go/vt/vttablet/tabletserver/vstreamer/planbuilder.go:902

			// This function is used when transforming datetime
			// values between the source and target.
			colnum, err := findColumn(plan.Table, aliased.As)
			if err != nil {
				return ColExpr{}, err
			}
			field := plan.Table.Fields[colnum]
			plan.setColumnFuncExpr(field.Name, inner)
			return ColExpr{
				ColNum: colnum,
				Field:  field,
			}, nil
		default:
			return ColExpr{}, fmt.Errorf("unsupported function: %v", sqlparser.String(inner))
		}
	case *sqlparser.Literal:
		// allow only intval 1
		if inner.Type != sqlparser.IntVal {
			return ColExpr{}, errors.New("only integer literals are supported")
		}
		num, err := strconv.ParseInt(string(inner.Val), 0, 64)
		if err != nil {
			return ColExpr{}, err
		}
		if num != 1 {
			return ColExpr{}, errors.New("only the integer literal 1 is supported")
		}
		return ColExpr{
			Field: &querypb.Field{
				Name:    "1",
				Type:    querypb.Type_INT64,
				Charset: collations.CollationBinaryID,
				Flags:   uint32(querypb.MySqlFlag_NOT_NULL_FLAG | querypb.MySqlFlag_NUM_FLAG),
			},
			ColNum:     -1,
			FixedValue: sqltypes.NewInt64(num),
		}, nil

View on GitHub (pinned to 01a25a7d17)