apache/seatunnel · error · UnsupportedOperationException

Unsupported convert ${value.getClass()} to LocalTime, typeDe

Error message

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

What it means

convertTime(TypeDefine, Object) tries Number, String, Duration and a few temporal types before giving up; if the value's class matches none of them it throws UnsupportedOperationException including the target typeDefine for diagnosis. The library throws it because there is no defined rule to interpret the value as a LocalTime.

Source

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

        if (value instanceof Time) {
            return convertLocalTime(typeDefine, (Time) value);
        }
        if (value instanceof LocalDateTime) {
            return convertLocalTime((LocalDateTime) value);
        }
        if (value instanceof java.sql.Timestamp) {
            return convertLocalTime((java.sql.Timestamp) value);
        }
        if (value instanceof String) {
            return convertLocalTime(typeDefine, (String) value);
        }
        if (value instanceof Number) {
            return convertLocalTime(typeDefine, (Number) value);
        }
        if (value instanceof Duration) {
            return convertLocalTime((Duration) value);
        }
        throw new UnsupportedOperationException(
                "Unsupported convert "
                        + value.getClass()
                        + " to LocalTime, typeDefine: "
                        + typeDefine);
    }

    default LocalTime convertLocalTime(T typeDefine, Time value) {
        return convertLocalTime(value);
    }

    default LocalTime convertLocalTime(T typeDefine, String value) {
        return convertLocalTime(value);
    }

    default LocalTime convertLocalTime(T typeDefine, Number value) {
        return convertLocalTime(value);
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read value.getClass() and typeDefine in the message to identify the offending class and target type
  2. Convert the value beforehand to one of the supported inputs: ISO LocalTime String, Number (nanos/millis per converter config), Duration, or LocalTime
  3. Add a custom DataConverter implementation for that class if the source always emits it
  4. Fix the schema mapping so the field type matches what the source actually produces

Example fix

// before
converter.convert(timeTypeDefine, javaSqlTimestamp); // throws
// after
LocalTime t = ((java.sql.Timestamp) javaSqlTimestamp).toLocalDateTime().toLocalTime();
converter.convert(timeTypeDefine, t);
Defensive patterns

Strategy: type-guard

Validate before calling

// before calling convert
if (!(v instanceof Number) && !(v instanceof String) && !(v instanceof java.time.Duration) && !(v instanceof java.time.temporal.TemporalAccessor)) {
    throw new IllegalStateException("Unsupported time class: " + v.getClass());
}

Type guard

boolean isTimeLike(Object v) {
    return v instanceof Number || v instanceof String
        || v instanceof java.time.Duration
        || v instanceof java.time.LocalTime;
}

Try / catch

try {
    LocalTime t = (LocalTime) converter.convert(typeDefine, value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Time conversion failed for class {}: {}", value.getClass(), e.getMessage());
    value = normalizeToTime(value); // fallback conversion
}

Prevention

When it happens

Trigger: Calling convert() with a TIME-mapped column when the value is an unhandled class — e.g. java.sql.Timestamp, byte[] from a binary protocol, or a micros-long wrapped in a non-Number type — so no branch in convertTime matches.

Common situations: CDC formats delivering time as struct/wrapped types; JDBC drivers returning java.sql.Time subclasses not matched by instanceof checks; schema mismatch where a source string column maps to a TIME sink column but carries non-ISO text.

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/c45aa41dacff33e5. Report an issue: GitHub.