{"record":{"id":"cf8fa9c1f7acb9b8","repo":"apache/iceberg","slug":"unsupported-to-derive-schema-for-type-logicalty","errorCode":null,"errorMessage":"Unsupported to derive Schema for type: ${logicalType}","messagePattern":"Unsupported to derive Schema for type: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L493-L529","documentation":"When converting TIMESTAMP_WITH_LOCAL_TIME_ZONE to an Avro schema with legacyTimestampMapping=true, there is no legacy Avro representation of a zoned timestamp, so the converter throws UnsupportedOperationException(\"Unsupported to derive Schema for type: \" + logicalType) unconditionally, regardless of precision.","triggerScenarios":"AvroSchemaConverter.convertToSchema(LogicalType, boolean) — directly or through fieldBuilder on any nested TIMESTAMP_WITH_LOCAL_TIME_ZONE field — while legacyTimestampMapping is true. E.g. a table containing TIMESTAMP_LTZ(3) columns converted with legacy mapping enabled.","commonSituations":"Legacy timestamp mapping enabled for backward compatibility with old Flink versions while the schema contains local-zoned timestamps introduced in newer Flink; migration of jobs from TIMESTAMP to TIMESTAMP_LTZ without updating the mapping flag.","solutions":["Set legacyTimestampMapping=false so TIMESTAMP_WITH_LOCAL_TIME_ZONE maps to instant/timestamp-micros logical types.","Change the column type to plain TIMESTAMP (without time zone) if the legacy writer must be kept.","Convert TIMESTAMP_LTZ columns to TIMESTAMP(3) via CAST in the query before writing.","Upgrade downstream Avro consumers that require the legacy mapping before disabling it."],"exampleFix":"// before\nSchema s = AvroSchemaConverter.convertToSchema(new LocalZonedTimestampType(3), true); // throws\n// after\nSchema s = AvroSchemaConverter.convertToSchema(new LocalZonedTimestampType(3), false); // instant logical type","handlingStrategy":"validation","validationCode":"if (legacyTimestampMapping && logicalType instanceof LocalZonedTimestampType) {\n  throw new IllegalStateException(\"TIMESTAMP_LTZ unsupported with legacy mapping; use legacyTimestampMapping=false\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  Schema s = AvroSchemaConverter.convertToSchema(ltzType, legacyMapping);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Unsupported to derive Schema for type:\")) {\n    s = AvroSchemaConverter.convertToSchema(ltzType, false); // switch to non-legacy mapping\n  } else throw e;\n}","preventionTips":["Scan schemas for TIMESTAMP_LTZ fields before enabling legacy timestamp mapping.","Use legacy mapping only for backward compatibility with pre-1.10 Flink consumers.","Convert TIMESTAMP_LTZ columns to TIMESTAMP if legacy writers are mandatory."],"tags":["avro","flink","timestamp","legacy-mapping"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}