vitessio/vitess · error

unsupported tenant column type: %s

Error message

unsupported tenant column type: %s

What it means

getTenantClause supports only INT64 and VARCHAR tenant column types. Any other querypb.Type for the tenant column falls into the default branch and produces this error, because the function cannot know how to render a safe SQL literal for that type.

Source

Thrown at go/vt/vtctl/workflow/utils.go:864

	}
	tenantColumnName := targetVSchema.MultiTenantSpec.TenantIdColumnName
	tenantColumnType := targetVSchema.MultiTenantSpec.TenantIdColumnType
	if tenantColumnName == "" {
		return nil, errors.New("tenant column name not defined in multi-tenant spec")
	}

	var tenantId string
	switch tenantColumnType {
	case querypb.Type_INT64:
		_, err := strconv.Atoi(vrOptions.TenantId)
		if err != nil {
			return nil, fmt.Errorf("tenant id is not a valid int: %s", vrOptions.TenantId)
		}
		tenantId = vrOptions.TenantId
	case querypb.Type_VARCHAR:
		tenantId = sqltypes.EncodeStringSQL(vrOptions.TenantId)
	default:
		return nil, fmt.Errorf("unsupported tenant column type: %s", tenantColumnType)
	}

	stmt, err := parser.Parse(fmt.Sprintf("select * from t where %s = %s", sqlescape.EscapeID(tenantColumnName), tenantId))
	if err != nil {
		return nil, err
	}
	sel, ok := stmt.(*sqlparser.Select)
	if !ok {
		return nil, fmt.Errorf("error getting select: %s", tenantId)
	}
	return &sel.Where.Expr, nil
}

func changeKeyspaceRouting(ctx context.Context, ts *topo.Server, tabletTypes []topodatapb.TabletType,
	sourceKeyspace, targetKeyspace, reason string,
) error {
	routes := make(map[string]string)
	for _, tabletType := range tabletTypes {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Change the tenant column to a supported type: BIGINT (INT64) or VARCHAR.
  2. Check the tenant column type via SHOW CREATE TABLE and confirm which querypb.Type it maps to.
  3. If you control the schema, alter the column type before running the tenant-filtered MoveTables.
  4. Extend getTenantClause to handle the needed type if you maintain a Vitess fork.

Example fix

// before
CREATE TABLE t (tenant_id INT, ...); // INT -> Type_INT32, unsupported
// after
ALTER TABLE t MODIFY tenant_id BIGINT; // Type_INT64, supported
Defensive patterns

Strategy: validation

Validate before calling

switch tenantColumnType {
case querypb.Type_INT64, querypb.Type_VARCHAR:
	// ok
default:
	return fmt.Errorf("tenant column type %s unsupported; use BIGINT or VARCHAR", tenantColumnType)
}

Type guard

func tenantTypeSupported(t querypb.Type) bool { return t == querypb.Type_INT64 || t == querypb.Type_VARCHAR }

Try / catch

clause, err := getTenantClause(...)
if err != nil {
	if strings.Contains(err.Error(), "unsupported tenant column type") {
		return fmt.Errorf("alter tenant column to BIGINT or VARCHAR before migrating: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Running tenant-aware MoveTables where the configured tenant column is of an unsupported type (e.g. INT32/UINT64/DECIMAL/enum in the schema — anything not mapped to querypb.Type_INT64 or Type_VARCHAR).

Common situations: Tenant column declared as BIGINT UNSIGNED or INT (maps to UINT64/INT32 in querypb), or a TEXT/ENUM column; schema uses a type the code never anticipated.

Related errors


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