{"record":{"id":"1ac254b17fd16f9e","repo":"apache/iceberg","slug":"unsupported-to-derive-schema-for-type-logical","errorCode":null,"errorMessage":"Unsupported to derive Schema for type: \" + logicalType","messagePattern":"Unsupported to derive Schema for type: \" \\+ logicalType","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java","lineNumber":511,"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":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L493-L529","documentation":"convertToSchema maps Flink LogicalTypes to Avro schemas. TIMESTAMP_WITH_LOCAL_TIME_ZONE has no Avro mapping when legacyTimestampMapping is true (legacy mode only knows local timestamp-millis semantics), so UnsupportedOperationException('Unsupported to derive Schema for type: ...') is thrown.","triggerScenarios":"Calling convertToSchema (directly or via fieldBuilder) with a LocalZonedTimestampType while legacyTimestampMapping=true.","commonSituations":"Legacy timestamp compatibility flag enabled (e.g. via table config / SQL legacy options) while the schema contains TIMESTAMP_LTZ columns; old connector configs carried over to newer Flink versions; mixing TZ-aware columns with legacy Avro writers.","solutions":["Disable legacy timestamp mapping (legacyTimestampMapping=false) so TIMESTAMP_WITH_LOCAL_TIME_ZONE maps to Avro timestamp-millis/micros logical types.","Change the column type to plain TIMESTAMP (without local time zone) if the legacy path is required.","Convert TIMESTAMP_LTZ values to a supported representation (e.g. BIGINT epoch or TIMESTAMP) upstream.","Align table configuration: the legacy flag and the schema's LTZ columns are mutually incompatible."],"exampleFix":"// before\nAvroSchemaConverter.convertToSchema(new LocalZonedTimestampType(3), true)\n// after\nAvroSchemaConverter.convertToSchema(new LocalZonedTimestampType(3), false)","handlingStrategy":"validation","validationCode":"if (logicalType instanceof LocalZonedTimestampType && legacyTimestampMapping) {\n  throw new IllegalArgumentException(\"TIMESTAMP_WITH_LOCAL_TIME_ZONE requires legacyTimestampMapping=false\");\n}","typeGuard":null,"tryCatchPattern":"try { schema = AvroSchemaConverter.convertToSchema(ltzType, legacy); } catch (UnsupportedOperationException e) { /* retry with legacy=false or convert column to TIMESTAMP */ }","preventionTips":["Audit table config for legacy timestamp flags when schemas include TIMESTAMP_LTZ.","Prefer non-legacy mapping in new pipelines.","Convert TIMESTAMP_LTZ to TIMESTAMP or BIGINT epoch when legacy writers are mandatory."],"tags":["flink","avro","timestamp","schema"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}