prestodb/presto · error · IllegalStateException

unsupported string field type:

Error message

unsupported string field type: 

What it means

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.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/GenericHiveRecordCursor.java:419

    private static Slice parseStringFromPrimitiveWritableObjectValue(Type type, Object fieldValue)
    {
        checkState(fieldValue != null, "fieldValue should not be null");
        BinaryComparable hiveValue;
        if (fieldValue instanceof Text) {
            hiveValue = (Text) fieldValue;
        }
        else if (fieldValue instanceof BytesWritable) {
            hiveValue = (BytesWritable) fieldValue;
        }
        else if (fieldValue instanceof HiveVarcharWritable) {
            hiveValue = ((HiveVarcharWritable) fieldValue).getTextValue();
        }
        else if (fieldValue instanceof HiveCharWritable) {
            hiveValue = ((HiveCharWritable) fieldValue).getTextValue();
        }
        else {
            throw new IllegalStateException("unsupported string field type: " + fieldValue.getClass().getName());
        }
        // create a slice view over the hive value and trim to character limits
        Slice value = trimStringToCharacterLimits(type, Slices.wrappedBuffer(hiveValue.getBytes(), 0, hiveValue.getLength()));
        // store a copy of the bytes, since the hive reader can reuse the underlying buffer
        return Slices.copyOf(value);
    }

    private static Slice parseStringFromPrimitiveJavaObjectValue(Type type, Object fieldValue)
    {
        checkState(fieldValue != null, "fieldValue should not be null");
        Slice value;
        if (fieldValue instanceof String) {
            value = Slices.utf8Slice((String) fieldValue);
        }
        else if (fieldValue instanceof byte[]) {
            value = Slices.wrappedBuffer((byte[]) fieldValue);
        }
        else if (fieldValue instanceof HiveVarchar) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the table's SerDe produces standard Hive string writables (Text, HiveVarcharWritable, HiveCharWritable) for string columns
  2. Correct the table schema so the column type matches the actual stored data
  3. Remove/replace custom SerDe configurations that emit unusual writable classes
  4. Upgrade Presto if the data uses a newer Hive writable type
  5. Fallback: read the table via a different connector/format that maps the field correctly

Example fix

// before: custom SerDe returns IntWritable for a 'string' column
props.setProperty('serde', 'com.example.WeirdSerDe');
// after: use a SerDe matching the schema
props.setProperty('serde', 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe');
Defensive patterns

Strategy: validation

Validate before calling

// before reading, confirm the SerDe's object inspector maps string columns to Text-like writables
ObjectInspector oi = serde.getObjectInspector();
Set<String> writableClasses = inspectorFieldClasses(oi, stringColumnIndex);
if (!writableClasses.contains("org.apache.hadoop.io.Text")) {
    throw new IllegalStateException("SerDe emits unsupported writable for string column");
}

Type guard

boolean isSupportedStringWritable(Object v) {
    return v instanceof Text || v instanceof HiveVarcharWritable || v instanceof HiveCharWritable;
}

Try / catch

try {
    cursor.parseStringColumn(column);
} catch (IllegalStateException e) {
    if (e.getMessage().startsWith("unsupported string field type:")) {
        // log the actual class name, fall back to a compatible SerDe
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/6bffaefcf430410a. Report an issue: GitHub.