{"record":{"id":"6bffaefcf430410a","repo":"prestodb/presto","slug":"unsupported-string-field-type","errorCode":null,"errorMessage":"unsupported string field type: ","messagePattern":"unsupported string field type: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/GenericHiveRecordCursor.java","lineNumber":419,"sourceCode":"\n    private static Slice parseStringFromPrimitiveWritableObjectValue(Type type, Object fieldValue)\n    {\n        checkState(fieldValue != null, \"fieldValue should not be null\");\n        BinaryComparable hiveValue;\n        if (fieldValue instanceof Text) {\n            hiveValue = (Text) fieldValue;\n        }\n        else if (fieldValue instanceof BytesWritable) {\n            hiveValue = (BytesWritable) fieldValue;\n        }\n        else if (fieldValue instanceof HiveVarcharWritable) {\n            hiveValue = ((HiveVarcharWritable) fieldValue).getTextValue();\n        }\n        else if (fieldValue instanceof HiveCharWritable) {\n            hiveValue = ((HiveCharWritable) fieldValue).getTextValue();\n        }\n        else {\n            throw new IllegalStateException(\"unsupported string field type: \" + fieldValue.getClass().getName());\n        }\n        // create a slice view over the hive value and trim to character limits\n        Slice value = trimStringToCharacterLimits(type, Slices.wrappedBuffer(hiveValue.getBytes(), 0, hiveValue.getLength()));\n        // store a copy of the bytes, since the hive reader can reuse the underlying buffer\n        return Slices.copyOf(value);\n    }\n\n    private static Slice parseStringFromPrimitiveJavaObjectValue(Type type, Object fieldValue)\n    {\n        checkState(fieldValue != null, \"fieldValue should not be null\");\n        Slice value;\n        if (fieldValue instanceof String) {\n            value = Slices.utf8Slice((String) fieldValue);\n        }\n        else if (fieldValue instanceof byte[]) {\n            value = Slices.wrappedBuffer((byte[]) fieldValue);\n        }\n        else if (fieldValue instanceof HiveVarchar) {","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/GenericHiveRecordCursor.java#L401-L437","documentation":"parseStringFromPrimitiveWritableObjectValue converts Hive Writable string values (Text, HiveVarcharWritable, HiveCharWritable, etc.) into Slice values. If the field value's class is none of the supported Writable string types, it throws IllegalStateException 'unsupported string field type: <class>'. This is a data/object-mapping integrity failure: the column is declared string-like but the SerDe produced an unexpected object.","triggerScenarios":"A Hive column typed string/varchar/char whose record cursor receives a Writable object other than Text/HiveVarcharWritable/HiveCharWritable — e.g. from a nonstandard SerDe returning different writables.","commonSituations":"Custom or misconfigured SerDes, reading a table whose declared schema does not match the stored data, or new Hive writable types not yet supported by the Presto reader version.","solutions":["Verify the table's SerDe produces standard Hive string writables (Text, HiveVarcharWritable, HiveCharWritable) for string columns","Correct the table schema so the column type matches the actual stored data","Remove/replace custom SerDe configurations that emit unusual writable classes","Upgrade Presto if the data uses a newer Hive writable type","Fallback: read the table via a different connector/format that maps the field correctly"],"exampleFix":"// before: custom SerDe returns IntWritable for a 'string' column\nprops.setProperty('serde', 'com.example.WeirdSerDe');\n// after: use a SerDe matching the schema\nprops.setProperty('serde', 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe');","handlingStrategy":"validation","validationCode":"// before reading, confirm the SerDe's object inspector maps string columns to Text-like writables\nObjectInspector oi = serde.getObjectInspector();\nSet<String> writableClasses = inspectorFieldClasses(oi, stringColumnIndex);\nif (!writableClasses.contains(\"org.apache.hadoop.io.Text\")) {\n    throw new IllegalStateException(\"SerDe emits unsupported writable for string column\");\n}","typeGuard":"boolean isSupportedStringWritable(Object v) {\n    return v instanceof Text || v instanceof HiveVarcharWritable || v instanceof HiveCharWritable;\n}","tryCatchPattern":"try {\n    cursor.parseStringColumn(column);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"unsupported string field type:\")) {\n        // log the actual class name, fall back to a compatible SerDe\n    }\n    throw e;\n}","preventionTips":["Use standard SerDes (LazySimpleSerDe, OpenCSVSerde) for string columns","Match declared column types to the SerDe's output types","Test custom SerDes against all column types before production"],"tags":["hive","serde","string","writable"],"backgroundTag":"unsupported-string-field-type","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}