{"record":{"id":"4f6247ad5ed45e62","repo":"googleapis/mcp-toolbox","slug":"unable-to-parse-row-w-4f6247","errorCode":null,"errorMessage":"unable to parse row: %w","messagePattern":"unable to parse row: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/trino/trino.go","lineNumber":139,"sourceCode":"\tdefer results.Close()\n\n\tcols, err := results.Columns()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to retrieve column names: %w\", err)\n\t}\n\n\t// create an array of values for each column, which can be re-used to scan each row\n\trawValues := make([]any, len(cols))\n\tvalues := make([]any, len(cols))\n\tfor i := range rawValues {\n\t\tvalues[i] = &rawValues[i]\n\t}\n\n\tout := []any{}\n\tfor results.Next() {\n\t\terr := results.Scan(values...)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to parse row: %w\", err)\n\t\t}\n\t\tvMap := make(map[string]any)\n\t\tfor i, name := range cols {\n\t\t\tval := rawValues[i]\n\t\t\tif val == nil {\n\t\t\t\tvMap[name] = nil\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Convert byte arrays to strings for text fields\n\t\t\tif b, ok := val.([]byte); ok {\n\t\t\t\tvMap[name] = string(b)\n\t\t\t} else {\n\t\t\t\tvMap[name] = val\n\t\t\t}\n\t\t}\n\t\tout = append(out, vMap)\n\t}","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/trino/trino.go#L121-L157","documentation":"Trino RunSQL wraps results.Scan(values...) failures for each row. Scan fails when the driver cannot convert a Trino column value into the destination Go value (typically *any / sql.RawBytes style slots), e.g. unexpected types, oversized values, or NULL handling mismatches.","triggerScenarios":"Source.RunSQL while iterating results: a row contains a value the trino driver cannot scan into the pre-allocated value slots — often complex types (map, row, array), hyperloglog/bitmap columns, or values exceeding buffer expectations.","commonSituations":"SELECT * on tables with nested/complex Trino types; datetime precision conversions; binary columns; driver version incompatibility with newer Trino type encodings.","solutions":["Cast complex columns in SQL to strings (e.g. CAST(col AS VARCHAR)) so they scan as text","Inspect the wrapped error for the offending column and type","Update trino-go-client and coordinator versions for type-encoding compatibility","Select only scalar columns needed instead of SELECT *"],"exampleFix":"// before\nSELECT * FROM events  -- includes map<string,string> payload\n// after\nSELECT id, ts, CAST(payload AS VARCHAR) AS payload FROM events","handlingStrategy":"fallback","validationCode":"// avoid complex types up front\nsafeStmt := strings.Replace(stmt, \"SELECT *\", \"SELECT id, ts, CAST(payload AS VARCHAR) AS payload\", 1)","typeGuard":null,"tryCatchPattern":"out, err := src.RunSQL(ctx, stmt, params)\nif err != nil && strings.Contains(err.Error(), \"unable to parse row\") {\n    // fallback: cast complex columns to VARCHAR and retry\n    out, err = src.RunSQL(ctx, castComplexColumnsToVarchar(stmt), params)\n}","preventionTips":["CAST map/row/array/hll columns AS VARCHAR in the statement","Select only the scalar columns you need","Keep driver and Trino server versions compatible","Test queries containing exotic types before production"],"tags":["database","trino","scan","type-conversion"],"backgroundTag":"scan-type-mismatch","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}