apache/seatunnel · error · UnsupportedOperationException

Unsupported convert ${value.getClass()} to Long, typeDefine:

Error message

Unsupported convert ${value.getClass()} to Long, typeDefine: ${typeDefine}

What it means

Thrown by BasicDataConverter.convertLong(T typeDefine, Object value) when the value is neither a LocalDate nor a LocalDateTime (nor handled by subclass branches such as Number, since the shown generic path only accepts date types before throwing). The converter converts date-time values to epoch-backed longs; anything else is rejected with the value class and type definition in the message.

Source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java:975

        if (value instanceof String) {
            return convertLong(typeDefine, (String) value);
        }
        if (value instanceof Time) {
            return convertLong(typeDefine, (Time) value);
        }
        if (value instanceof LocalTime) {
            return convertLong(typeDefine, (LocalTime) value);
        }
        if (value instanceof Date) {
            return convertLong(typeDefine, (Date) value);
        }
        if (value instanceof LocalDate) {
            return convertLong(typeDefine, (LocalDate) value);
        }
        if (value instanceof LocalDateTime) {
            return convertLong(typeDefine, (LocalDateTime) value);
        }
        throw new UnsupportedOperationException(
                "Unsupported convert " + value.getClass() + " to Long, typeDefine: " + typeDefine);
    }

    default long convertLong(T typeDefine, Number value) {
        return convertLong(value);
    }

    default long convertLong(T typeDefine, String value) {
        return convertLong(value);
    }

    default long convertLong(T typeDefine, Time value) {
        return convertLong(value);
    }

    default long convertLong(T typeDefine, LocalTime value) {
        return convertLong(value);
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Align the field schema with the converter expectations: declare the column as TIMESTAMP if the value is a date, or convert the value to Number/LocalDate before conversion
  2. If the value is java.util.Date or String, convert it: toInstant().toEpochMilli() or LocalDate.parse(...)/Long.parseLong(...) before calling convertLong
  3. Override convertLong(T typeDefine, Object value) in a custom converter to add the missing class branch

Example fix

// before
long l = converter.convertLong(typeDefine, row.getField(0)); // java.util.Date throws
// after
Object v = row.getField(0);
long l = (v instanceof java.util.Date)
        ? ((java.util.Date) v).toInstant().toEpochMilli()
        : converter.convertLong(typeDefine, v);
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = row.getField(0);
if (!(v instanceof Number) && !(v instanceof LocalDate) && !(v instanceof LocalDateTime)) {
    throw new IllegalArgumentException("Value " + v.getClass() + " is not convertible to LONG");
}

Type guard

static boolean isLongConvertible(Object v) {
    return v instanceof Number || v instanceof LocalDate || v instanceof LocalDateTime;
}

Try / catch

try {
    l = converter.convertLong(typeDefine, value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Inconvertible value {} for BIGINT: {}", value, e.getMessage());
    l = 0L;
}

Prevention

When it happens

Trigger: Calling convertLong(typeDefine, value) with e.g. a String, Number outside the overloaded branch, java.util.Date, byte[] or a nested object where a LocalDate/LocalDateTime (or numeric) is required, when mapping a field to a BIGINT column.

Common situations: A source connector returns java.util.Date or String timestamps but the catalog declares BIGINT; after a library upgrade date handling moved from Number to LocalDate branches; custom transforms feed raw objects into long columns.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/15e6b56b14080666. Report an issue: GitHub.