{"record":{"id":"bfb5fa90aa40b184","repo":"apache/iceberg","slug":"unexpected-object-type-for-time-logical-type-rece-bfb5fa","errorCode":null,"errorMessage":"Unexpected object type for TIME logical type. Received: \" + object","messagePattern":"Unexpected object type for TIME logical type\\. Received: \" \\+ object","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/AvroToRowDataConverters.java","lineNumber":284,"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":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/AvroToRowDataConverters.java#L266-L302","documentation":"convertToTime converts the Avro-decoded object for a TIME logical type into millis-of-day int. It supports java.time.LocalTime and Joda objects via JodaConverter; otherwise it throws IllegalArgumentException(\"Unexpected object type for TIME logical type. Received: \" + object). It indicates the runtime decoded object doesn't match the TIME logical type.","triggerScenarios":"An Avro 'time-millis'/'time-micros' field decodes to an unexpected object (e.g. plain int because the schema omitted the logical type), or Joda data with joda-time missing from the runtime.","commonSituations":"Schema evolution where the producer dropped the time logicalType; missing joda-time dependency; hand-built Avro GenericRecord values bypassing logical type conversion.","solutions":["Ensure the Avro schema declares the time logicalType so decoding yields LocalTime.","Add joda-time to the runtime classpath for legacy Joda-encoded times.","Align the Flink column type (e.g. INT/TIME) with what the data actually contains."],"exampleFix":"// before\n{ \"name\": \"t\", \"type\": \"int\" } // decoded as Integer\n// after\n{ \"name\": \"t\", \"type\": { \"type\": \"int\", \"logicalType\": \"time-millis\" } }","handlingStrategy":"type-guard","validationCode":"if (!(avroObject instanceof LocalTime) && JodaConverter.getConverter() == null) { throw new IllegalStateException(\"TIME field decodes to \" + avroObject.getClass() + \" and Joda converter unavailable\"); }","typeGuard":"boolean isSupportedTimeObject(Object o) { return o instanceof LocalTime || (isJodaTime(o) && JodaConverter.getConverter() != null); }","tryCatchPattern":"try { int millis = convertToTime(avroObject); } catch (IllegalArgumentException e) { /* inspect received type in message */ }","preventionTips":["Ensure Avro schemas declare time-millis/time-micros logicalType for time fields.","Include joda-time when consuming legacy-encoded times.","Round-trip test Avro serialize/deserialize for time columns."],"tags":["flink","avro","time","type-mismatch"],"backgroundTag":"unexpected-response-shape","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"}