{"record":{"id":"1f168d248c91ba7f","repo":"apache/flink","slug":"unexpected-object-type-for-time-logical-type-rece","errorCode":null,"errorMessage":"Unexpected object type for TIME logical type. Received: {}","messagePattern":"Unexpected object type for TIME logical type\\. Received: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroToRowDataConverters.java","lineNumber":261,"sourceCode":"            } else {\n                throw new IllegalArgumentException(\n                        \"Unexpected object type for DATE logical type. Received: \" + object);\n            }\n        }\n    }\n\n    private static int convertToTime(Object object) {\n        final int millis;\n        if (object instanceof Integer) {\n            millis = (Integer) object;\n        } else if (object instanceof LocalTime) {\n            millis = ((LocalTime) object).get(ChronoField.MILLI_OF_DAY);\n        } else {\n            JodaConverter jodaConverter = JodaConverter.getConverter();\n            if (jodaConverter != null) {\n                millis = jodaConverter.convertTime(object);\n            } else {\n                throw new IllegalArgumentException(\n                        \"Unexpected object type for TIME logical type. Received: \" + object);\n            }\n        }\n        return millis;\n    }\n\n    private static byte[] convertToBytes(Object object) {\n        if (object instanceof GenericFixed) {\n            return ((GenericFixed) object).bytes();\n        } else if (object instanceof ByteBuffer) {\n            ByteBuffer byteBuffer = (ByteBuffer) object;\n            byte[] bytes = new byte[byteBuffer.remaining()];\n            byteBuffer.get(bytes);\n            return bytes;\n        } else {\n            return (byte[]) object;\n        }\n    }","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroToRowDataConverters.java#L243-L279","documentation":"convertToTime accepts only Integer (millis of day) or java.time.LocalTime (plus Joda when available). Any other object decoded for a TIME logical-type field throws IllegalArgumentException with the received value.","triggerScenarios":"Writer schema has no 'time-millis' logicalType on the int field (yielding a non-Integer decode path is rare, but strings/longs appear with mismatched schemas), or the producer encodes times as strings/longs.","commonSituations":"Time stored as 'HH:mm:ss' strings by another tool; schema evolution removing logical type annotations; precision mismatch producing Long where Integer expected.","solutions":["Declare {\"type\":\"int\",\"logicalType\":\"time-millis\"} in the writer schema and encode as int millis-of-day.","Read string-encoded times as STRING and CAST to TIME in SQL.","Pre-convert time values to millis-of-day before writing Avro."],"exampleFix":"// before\n// field encoded as \"12:30:00\" string, mapped to TIME(3)\n\n// after\n// writer schema: {\"name\":\"t\",\"type\":{\"type\":\"int\",\"logicalType\":\"time-millis\"}}\n// or SQL: CAST(t AS TIME(3)) over a STRING column","handlingStrategy":"type-guard","validationCode":"Object v = record.get(fieldPos);\nif (!(v instanceof Integer) && !(v instanceof LocalTime)\n        && JodaConverter.getConverter() == null) {\n    throw new IllegalArgumentException(\"Unconvertible time value class: \" + v.getClass());\n}","typeGuard":"static boolean isAvroTimeValue(Object v) {\n    return v instanceof Integer || v instanceof LocalTime;\n}","tryCatchPattern":null,"preventionTips":["Encode times as int millis-of-day with the time-millis logicalType.","Use SQL CAST for string-encoded times instead of the logical-type path."],"tags":["avro","flink","time","logical-type","schema-mismatch"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}