{"record":{"id":"145fd24bcd6f96e4","repo":"vitessio/vitess","slug":"failed-to-find-column-name-for-convert-using-expre-145fd2","errorCode":null,"errorMessage":"failed to find column name for convert using expression: %v, %v","messagePattern":"failed to find column name for convert using expression: (.+?), (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletserver/vstreamer/planbuilder.go","lineNumber":939,"sourceCode":"\tcase *sqlparser.ConvertUsingExpr:\n\t\t// Here we find the actual column name in the convert, in case\n\t\t// this is a column rename and the AS is the new column.\n\t\t// For example, in convert(c1 using utf8mb4) as c2, we want to find\n\t\t// c1, because c1 exists in the current table whereas c2 is the renamed column\n\t\t// in the desired table.\n\t\tvar colName sqlparser.IdentifierCI\n\t\terr := sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {\n\t\t\tswitch node := node.(type) {\n\t\t\tcase *sqlparser.ColName:\n\t\t\t\tif !node.Qualifier.IsEmpty() {\n\t\t\t\t\treturn false, fmt.Errorf(\"unsupported qualifier for column: %v\", sqlparser.String(node))\n\t\t\t\t}\n\t\t\t\tcolName = node.Name\n\t\t\t}\n\t\t\treturn true, nil\n\t\t}, aliased.Expr)\n\t\tif err != nil {\n\t\t\treturn ColExpr{}, fmt.Errorf(\"failed to find column name for convert using expression: %v, %v\", sqlparser.String(aliased.Expr), err)\n\t\t}\n\t\tcolnum, err := findColumn(plan.Table, colName)\n\t\tif err != nil {\n\t\t\treturn ColExpr{}, err\n\t\t}\n\t\tfield := plan.Table.Fields[colnum]\n\t\tplan.setConvertColumnUsingUTF8(field.Name)\n\t\treturn ColExpr{\n\t\t\tColNum: colnum,\n\t\t\tField:  field,\n\t\t}, nil\n\tdefault:\n\t\tlog.Info(fmt.Sprintf(\"Unsupported expression: %v\", inner))\n\t\treturn ColExpr{}, fmt.Errorf(\"unsupported: %v\", sqlparser.String(aliased.Expr))\n\t}\n}\n\n// analyzeInKeyRange allows the following constructs: \"in_keyrange('-80')\",","sourceCodeStart":921,"sourceCodeEnd":957,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go#L921-L957","documentation":"When processing a convert_tz expression, analyzeExpr walks the expression tree to discover which column it applies to; if the walk returns an error (typically the 'unsupported qualifier for column' error above), this message wraps it, and if no column is found, findColumn also fails into this wrapper, reporting the full expression and the underlying error.","triggerScenarios":"A convert_tz(...) select expression whose inner column reference is qualified (e.g. convert_tz(t.ts, ...) as ts) so the walk errors before assigning colName.","commonSituations":"Qualified columns inside convert_tz in vstream selects; copy-pasted queries with table qualifiers into a vstreamer-based conversion flow.","solutions":["Use an unqualified column inside convert_tz: convert_tz(ts, '%s', ...) as ts.","Alias the expression (as <column_name>) so findColumn can locate it in the table's fields.","Verify the aliased name matches a real column of the streamed table."],"exampleFix":"// before\nselect convert_tz(t.ts, '+00:00', '+05:30') as ts from t\n// after\nselect convert_tz(ts, '+00:00', '+05:30') as ts from t","handlingStrategy":"validation","validationCode":"// ensure convert_tz args contain an unqualified column and the expr is aliased to a real column\nif !strings.Contains(expr, \"convert_tz\") {\n    return nil\n}\nif hasQualifier(expr) {\n    return fmt.Errorf(\"convert_tz must reference an unqualified column: %s\", expr)\n}\nif aliasedTo, ok := aliasOf(expr); !ok || !columnExists(table, aliasedTo) {\n    return fmt.Errorf(\"convert_tz expression must be aliased to an existing column\")\n}","typeGuard":"func isAliasedConvertTz(expr string) (string, bool) {\n    parts := strings.Split(expr, \" as \")\n    if len(parts) == 2 && strings.Contains(parts[0], \"convert_tz\") {\n        return strings.TrimSpace(parts[1]), true\n    }\n    return \"\", false\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to find column name for convert using expression\") {\n    return fmt.Errorf(\"make convert_tz reference an unqualified, aliased column: %w\", err)\n}","preventionTips":["Alias convert_tz expressions to the target column name","Use unqualified columns inside convert_tz","Verify the alias matches an actual field of the streamed table"],"tags":["vstreamer","vstream-results","convert-tz","sql-syntax"],"backgroundTag":"unsupported-vstream-expression","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}