{"record":{"id":"8932563373f8f3e5","repo":"vitessio/vitess","slug":"unsupported-tenant-column-type-s","errorCode":null,"errorMessage":"unsupported tenant column type: %s","messagePattern":"unsupported tenant column type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/utils.go","lineNumber":864,"sourceCode":"\t}\n\ttenantColumnName := targetVSchema.MultiTenantSpec.TenantIdColumnName\n\ttenantColumnType := targetVSchema.MultiTenantSpec.TenantIdColumnType\n\tif tenantColumnName == \"\" {\n\t\treturn nil, errors.New(\"tenant column name not defined in multi-tenant spec\")\n\t}\n\n\tvar tenantId string\n\tswitch tenantColumnType {\n\tcase querypb.Type_INT64:\n\t\t_, err := strconv.Atoi(vrOptions.TenantId)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"tenant id is not a valid int: %s\", vrOptions.TenantId)\n\t\t}\n\t\ttenantId = vrOptions.TenantId\n\tcase querypb.Type_VARCHAR:\n\t\ttenantId = sqltypes.EncodeStringSQL(vrOptions.TenantId)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported tenant column type: %s\", tenantColumnType)\n\t}\n\n\tstmt, err := parser.Parse(fmt.Sprintf(\"select * from t where %s = %s\", sqlescape.EscapeID(tenantColumnName), tenantId))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsel, ok := stmt.(*sqlparser.Select)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"error getting select: %s\", tenantId)\n\t}\n\treturn &sel.Where.Expr, nil\n}\n\nfunc changeKeyspaceRouting(ctx context.Context, ts *topo.Server, tabletTypes []topodatapb.TabletType,\n\tsourceKeyspace, targetKeyspace, reason string,\n) error {\n\troutes := make(map[string]string)\n\tfor _, tabletType := range tabletTypes {","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/utils.go#L846-L882","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Change the tenant column to a supported type: BIGINT (INT64) or VARCHAR.","Check the tenant column type via SHOW CREATE TABLE and confirm which querypb.Type it maps to.","If you control the schema, alter the column type before running the tenant-filtered MoveTables.","Extend getTenantClause to handle the needed type if you maintain a Vitess fork."],"exampleFix":"// before\nCREATE TABLE t (tenant_id INT, ...); // INT -> Type_INT32, unsupported\n// after\nALTER TABLE t MODIFY tenant_id BIGINT; // Type_INT64, supported","handlingStrategy":"validation","validationCode":"switch tenantColumnType {\ncase querypb.Type_INT64, querypb.Type_VARCHAR:\n\t// ok\ndefault:\n\treturn fmt.Errorf(\"tenant column type %s unsupported; use BIGINT or VARCHAR\", tenantColumnType)\n}","typeGuard":"func tenantTypeSupported(t querypb.Type) bool { return t == querypb.Type_INT64 || t == querypb.Type_VARCHAR }","tryCatchPattern":"clause, err := getTenantClause(...)\nif err != nil {\n\tif strings.Contains(err.Error(), \"unsupported tenant column type\") {\n\t\treturn fmt.Errorf(\"alter tenant column to BIGINT or VARCHAR before migrating: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Schema-review tenant columns to ensure they are BIGINT or VARCHAR before tenant-aware migrations","Map your MySQL type to querypb.Type mentally: INT/SMALLINT map to INT32 etc. and are NOT supported","Add a pre-migration schema check script that asserts the tenant column type"],"tags":["validation","tenant","schema","movetables"],"backgroundTag":"unsupported-column-type","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}