{"record":{"id":"d643e84db1a1a323","repo":"apache/flink","slug":"unsupported-to-derive-schema-for-type-s","errorCode":null,"errorMessage":"Unsupported to derive Schema for type: %s","messagePattern":"Unsupported to derive Schema for type: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java","lineNumber":494,"sourceCode":"                    }\n                } else {\n                    if (precision <= 3) {\n                        avroLogicalType = LogicalTypes.localTimestampMillis();\n                    } else if (precision <= 6) {\n                        avroLogicalType = LogicalTypes.localTimestampMicros();\n                    } else {\n                        throw new IllegalArgumentException(\n                                \"Avro does not support LOCAL TIMESTAMP type \"\n                                        + \"with precision: \"\n                                        + precision\n                                        + \", it only supports precision less than 6.\");\n                    }\n                }\n                Schema timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());\n                return nullable ? nullableSchema(timestamp) : timestamp;\n            case TIMESTAMP_WITH_LOCAL_TIME_ZONE:\n                if (legacyTimestampMapping) {\n                    throw new UnsupportedOperationException(\n                            \"Unsupported to derive Schema for type: \" + logicalType);\n                } else {\n                    final LocalZonedTimestampType localZonedTimestampType =\n                            (LocalZonedTimestampType) logicalType;\n                    precision = localZonedTimestampType.getPrecision();\n                    if (precision <= 3) {\n                        avroLogicalType = LogicalTypes.timestampMillis();\n                    } else if (precision <= 6) {\n                        avroLogicalType = LogicalTypes.timestampMicros();\n                    } else {\n                        throw new IllegalArgumentException(\n                                \"Avro does not support TIMESTAMP type \"\n                                        + \"with precision: \"\n                                        + precision\n                                        + \", it only supports precision less than 6.\");\n                    }\n                    timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());\n                    return nullable ? nullableSchema(timestamp) : timestamp;","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java#L476-L512","documentation":"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.","triggerScenarios":"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.","commonSituations":"Jobs migrated from Flink <=1.11 that kept legacy timestamp behaviour and now add a TIMESTAMP_LTZ column for Kafka/Avro sinks.","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."],"exampleFix":"// before: legacy mapping + TIMESTAMP_LTZ\nSchema s = AvroSchemaConverter.convertToSchema(ltzType, /*legacyTimestampMapping=*/ true);\n\n// after\nSchema s = AvroSchemaConverter.convertToSchema(ltzType, /*legacyTimestampMapping=*/ false);","handlingStrategy":"validation","validationCode":"import org.apache.flink.table.types.logical.LocalZonedTimestampType;\n\nvoid assertConvertible(LocalZonedTimestampType t, boolean legacyMapping) {\n    if (legacyMapping) {\n        throw new UnsupportedOperationException(\n            \"TIMESTAMP WITH LOCAL TIME ZONE cannot be written to Avro under legacy mapping\");\n    }\n}","typeGuard":"boolean avroConvertible(LocalZonedTimestampType t, boolean legacy) { return !legacy; }","tryCatchPattern":null,"preventionTips":["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."],"tags":["avro","timestamp-ltz","flink","schema-conversion","legacy"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}