apache/flink · error · UnsupportedOperationException
Unsupported to derive Schema for type: %s
Error message
Unsupported to derive Schema for type: %s
What it means
UnsupportedOperationException thrown when converting TIMESTAMP WITH LOCAL TIME ZONE to an Avro schema while legacy timestamp mapping is enabled. Under legacy semantics Flink could not distinguish TIMESTAMP WITH LOCAL TIME ZONE, so no Avro logical type was defined for it; the conversion is deliberately blocked rather than producing a wrong mapping.
Source
Thrown at flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java:494
}
} else {
if (precision <= 3) {
avroLogicalType = LogicalTypes.localTimestampMillis();
} else if (precision <= 6) {
avroLogicalType = LogicalTypes.localTimestampMicros();
} else {
throw new IllegalArgumentException(
"Avro does not support LOCAL TIMESTAMP type "
+ "with precision: "
+ precision
+ ", it only supports precision less than 6.");
}
}
Schema timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());
return nullable ? nullableSchema(timestamp) : timestamp;
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
if (legacyTimestampMapping) {
throw new UnsupportedOperationException(
"Unsupported to derive Schema for type: " + logicalType);
} else {
final LocalZonedTimestampType localZonedTimestampType =
(LocalZonedTimestampType) logicalType;
precision = localZonedTimestampType.getPrecision();
if (precision <= 3) {
avroLogicalType = LogicalTypes.timestampMillis();
} else if (precision <= 6) {
avroLogicalType = LogicalTypes.timestampMicros();
} else {
throw new IllegalArgumentException(
"Avro does not support TIMESTAMP type "
+ "with precision: "
+ precision
+ ", it only supports precision less than 6.");
}
timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());
return nullable ? nullableSchema(timestamp) : timestamp;View on GitHub (pinned to 2f3c205e92)
Solutions
- Disable legacy timestamp mapping (unset table.exec.legacy-timestamp-behaviour / legacy option) so TIMESTAMP_LTZ maps to timestamp-millis/micros.
- If legacy behaviour must stay, change the column to TIMESTAMP WITHOUT TIME ZONE or store epoch millis as BIGINT.
Example fix
// before: legacy mapping + TIMESTAMP_LTZ Schema s = AvroSchemaConverter.convertToSchema(ltzType, /*legacyTimestampMapping=*/ true); // after Schema s = AvroSchemaConverter.convertToSchema(ltzType, /*legacyTimestampMapping=*/ false);
Defensive patterns
Strategy: validation
Validate before calling
import org.apache.flink.table.types.logical.LocalZonedTimestampType;
void assertConvertible(LocalZonedTimestampType t, boolean legacyMapping) {
if (legacyMapping) {
throw new UnsupportedOperationException(
"TIMESTAMP WITH LOCAL TIME ZONE cannot be written to Avro under legacy mapping");
}
} Type guard
boolean avroConvertible(LocalZonedTimestampType t, boolean legacy) { return !legacy; } Prevention
- Do not combine TIMESTAMP_LTZ columns with legacy timestamp behaviour on avro sinks.
- When migrating old jobs, drop legacy timestamp options before introducing LTZ columns.
When it happens
Trigger: convertToSchema(logicalType, legacyTimestampMapping=true) where logicalType is TIMESTAMP_LTZ; an avro/avro-confluent-registry table with a TIMESTAMP(3) WITH LOCAL TIME ZONE column while legacy timestamp behaviour is on.
Common situations: Jobs migrated from Flink <=1.11 that kept legacy timestamp behaviour and now add a TIMESTAMP_LTZ column for Kafka/Avro sinks.
Related errors
- Avro does not support TIMESTAMP type with precision: %s, it
- Unsupported type: {}
- Avro does not support TIMESTAMP type with precision: %s, it
- Avro does not support LOCAL TIMESTAMP type with precision: %
- Avro does not support TIME type with precision: %s, it only
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/d643e84db1a1a323.
Report an issue: GitHub.