{"record":{"id":"0c7c1d1595a47839","repo":"apache/iceberg","slug":"unsupported-to-derive-schema-for-type","errorCode":null,"errorMessage":"Unsupported to derive Schema for type: ","messagePattern":"Unsupported to derive Schema for type: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/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.3/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L493-L529","documentation":"Thrown when converting a Flink TIMESTAMP_WITH_LOCAL_TIME_ZONE logical type to an Avro schema while legacyTimestampMapping=true. Legacy mapping has no Avro logical type for zoned timestamps, so this case is explicitly rejected with UnsupportedOperationException. Using the non-legacy mapping (timestampMillis/timestampMicros) resolves it.","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema(LogicalType, boolean) with a LocalZonedTimestampType while legacyTimestampMapping is true.","commonSituations":"Tables containing TIMESTAMPTZ / TIMESTAMP WITH LOCAL TIME ZONE columns written to Avro with legacy mapping enabled from an older Flink/Iceberg configuration.","solutions":["Set legacyTimestampMapping=false when calling convertToSchema.","Remove the legacy timestamp mapping option from the connector/format config.","If legacy mode cannot be disabled, cast the column to TIMESTAMP (without time zone).","Upgrade Flink/Iceberg if legacy mapping is forced by an old version's defaults."],"exampleFix":"// before\nAvroSchemaConverter.convertToSchema(localZonedTimestampType, true); // throws\n// after\nAvroSchemaConverter.convertToSchema(localZonedTimestampType, false); // timestampMillis/Micros","handlingStrategy":"validation","validationCode":"if (logicalType instanceof LocalZonedTimestampType && legacyTimestampMapping) { /* disable legacy mapping or cast to TIMESTAMP without time zone */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never enable legacy timestamp mapping if the schema contains zoned timestamps.","Remove deprecated legacy-mapping flags from connector configs.","Audit schemas for TIMESTAMPTZ columns before choosing Avro options.","Cast TIMESTAMPTZ to TIMESTAMP if legacy mode is unavoidable."],"tags":["flink","avro","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"}