vitessio/vitess · error

unknown SQL type %q at %s

Error message

unknown SQL type %q at %s

What it means

ParseRows parses a human-readable rows string where each value can carry a type annotation in parentheses. It throws when the annotation is not a recognized querypb.Type name, reporting the identifier and scan position.

Source

Thrown at go/sqltypes/parse_rows.go:87

			}
		case stInRow:
			switch tok {
			case ']':
				result = append(result, row)
				row = nil
				next = stBeginRow
			case scanner.Ident:
				ident := scan.TokenText()

				if ident == "NULL" {
					row = append(row, NULL)
					continue
				}

				var ok bool
				vtype, ok = querypb.Type_value[ident]
				if !ok {
					return nil, fmt.Errorf("unknown SQL type %q at %s", ident, scan.Position)
				}
				next = stInValue0
			}
		case stInValue0:
			if tok == '(' {
				next = stInValue1
			}
		case stInValue1:
			literal := scan.TokenText()
			switch tok {
			case scanner.String:
				var err error
				literal, err = strconv.Unquote(literal)
				if err != nil {
					return nil, fmt.Errorf("failed to parse literal string at %s: %w", scan.Position, err)
				}
				fallthrough
			case scanner.Int, scanner.Float:

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Use exact querypb.Type_value names in annotations, e.g. (INT64), (VARCHAR), (VARBINARY)
  2. Check go/vt/proto/query querypb.Type_value map for the valid identifier list
  3. Fix the typo or outdated type name in the rows string

Example fix

// before
rows := sqltypes.MakeTestRows(strings.NewReader("(VARCHAR 'abc')"))
// after
rows := sqltypes.MakeTestRows(strings.NewReader("(VARCHAR 'abc')")) // -> use querypb name:
// (VARCHAR is valid only if in querypb.Type_value; otherwise use e.g. (VARBINARY 'abc'))
Defensive patterns

Strategy: validation

Validate before calling

func validTypeName(ident string) bool {
	_, ok := querypb.Type_value[ident]
	return ok
}

Type guard

func isKnownSQLType(ident string) bool { _, ok := querypb.Type_value[ident]; return ok }

Try / catch

rows, err := sqltypes.ParseRows(input, cols)
if err != nil {
	return fmt.Errorf("bad test rows input at %v: %v", err, input)
}

Prevention

When it happens

Trigger: Calling ParseRows (directly or via RowsEqualsStr in tests) with a type annotation like (VARCHAR) or (INT) that is not an exact querypb.Type_value key — valid names include INT64, VARCHAR, VARBINARY, DATETIME, etc.

Common situations: Writing expected rows in unit tests with MySQL-style or made-up type names instead of Vitess/querypb enum names; typos in annotations; copying examples from an older version with different type names.

Related errors


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