prestodb/presto · error · UnsupportedOperationException

Unsupported type '%s' for column '%s'

Error message

Unsupported type '%s' for column '%s'

What it means

AbstractRowEncoder is a template base class for Kafka row encoders. Each concrete encoder (JSON, CSV, Avro, Raw) overrides only the append* methods for the primitive types its data format supports; this default appendLong body is the unsupported fallback. It throws when a row is being encoded and a BIGINT column value reaches an encoder that did not override appendLong, meaning the chosen encoder cannot represent that column type.

Source

Thrown at presto-kafka/src/main/java/com/facebook/presto/kafka/encoder/AbstractRowEncoder.java:136

        else if (type instanceof TimestampWithTimeZoneType) {
            appendSqlTimestampWithTimeZone((SqlTimestampWithTimeZone) type.getObjectValue(session.getSqlFunctionProperties(), block, position));
        }
        else {
            throw new UnsupportedOperationException(format("Column '%s' does not support 'null' value", columnHandles.get(currentColumnIndex).getName()));
        }
        currentColumnIndex++;
    }

    // these append value methods should be overridden for each row encoder
    // only the methods with types supported by the data format should be overridden
    protected void appendNullValue()
    {
        throw new UnsupportedOperationException(format("Column '%s' does not support 'null' value", columnHandles.get(currentColumnIndex).getName()));
    }

    protected void appendLong(long value)
    {
        throw new UnsupportedOperationException(format("Unsupported type '%s' for column '%s'", long.class.getName(), columnHandles.get(currentColumnIndex).getName()));
    }

    protected void appendInt(int value)
    {
        throw new UnsupportedOperationException(format("Unsupported type '%s' for column '%s'", int.class.getName(), columnHandles.get(currentColumnIndex).getName()));
    }

    protected void appendShort(short value)
    {
        throw new UnsupportedOperationException(format("Unsupported type '%s' for column '%s'", short.class.getName(), columnHandles.get(currentColumnIndex).getName()));
    }

    protected void appendByte(byte value)
    {
        throw new UnsupportedOperationException(format("Unsupported type '%s' for column '%s'", byte.class.getName(), columnHandles.get(currentColumnIndex).getName()));
    }

    protected void appendDouble(double value)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Remove the BIGINT column from the topic's column list, or cast it to VARCHAR in the query (e.g. CAST(col AS VARCHAR)) so appendLong is never dispatched.
  2. Change the topic's encoder data_format in the topic description file to one that supports BIGINT (e.g. 'json' or 'avro' instead of 'raw').
  3. If writing a custom encoder, override appendLong(long) in your AbstractRowEncoder subclass to handle BIGINT values.

Example fix

// before: RawEncoder with a BIGINT column
CREATE TABLE kafka_news WITH (topic='events', data_format='raw', columns=[... 'seq' BIGINT ...]) ...
// after: cast the BIGINT column to VARCHAR in the topic definition
'seq' VARCHAR  -- or query with CAST(seq AS VARCHAR)
Defensive patterns

Strategy: validation

Validate before calling

// Before writing, verify the encoder supports BIGINT columns:
for (EncoderColumnHandle col : columnHandles) {
    if (col.getType().equals(BigintType.BIGINT)) {
        throw new IllegalArgumentException("Encoder data_format for topic " + topicName
            + " does not support BIGINT column " + col.getName());
    }
}

Try / catch

// At INSERT time, wrap row encoding so the message names the offending column:
try {
    rowEncoder.appendColumnValue(block, position);
}
catch (UnsupportedOperationException e) {
    throw new PrestoException(KafkaErrorCode.KAFKA_ENCODER_ERROR, e.getMessage()
        + "; check that data_format='" + dataFormat + "' supports the declared column types", e);
}

Prevention

When it happens

Trigger: appendColumnValue (AbstractRowEncoder.java:82-83) dispatches to appendLong when the EncoderColumnHandle's type is BigintType.BIGINT and the block value is non-null, and the concrete row encoder subclass has not overridden appendLong.

Common situations: A Kafka topic definition (etc/kafka.properties topic description) declares a column of type BIGINT but the encoder configured for the topic (e.g. RawEncoder, which supports only bytes/varchar, or CSV encoder with limited type support) cannot encode BIGINT. Also happens when switching a topic's data_format from JSON/Avro to 'raw' without dropping BIGINT columns from the column list.

Related errors


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