{"record":{"id":"bdda4c9258a59155","repo":"apache/iceberg","slug":"unexpected-object-type-for-time-logical-type-rece","errorCode":null,"errorMessage":"Unexpected object type for TIME logical type. Received: ${object}","messagePattern":"Unexpected object type for TIME logical type\\. Received: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/formats/avro/AvroToRowDataConverters.java#L266-L302","documentation":"convertToTime converts an Avro TIME logical-type value into millis-of-day for Flink TIME. Expected inputs are LocalTime or Joda-handled types; anything else (with no Joda converter available) triggers this IllegalArgumentException identifying the actual object.","triggerScenarios":"Avro TIME field decoded as a class other than LocalTime (e.g. Long micros/millis) while legacyTimestampMapping expectations differ, or joda-time missing so JodaConverter is null for legacy Joda-encoded times.","commonSituations":"Files written with legacy time-unit encoding read by a converter expecting modern types; missing joda-time dependency; schema property mapping changed without data rewrite.","solutions":["Align the table's time-unit mapping property with the actual file encoding and rewrite files if necessary.","Add the joda-time dependency when reading legacy Joda-encoded TIME values.","Check the 'Received:' class in the message and pre-convert that value (e.g. Long millis → LocalTime) before conversion."],"exampleFix":"// before\nObject v = record.get(\"t\"); // Long millis\nRowData row = converter.convert(record); // throws\n// after\nrecord.put(\"t\", LocalTime.ofNanoOfDay((Long) v * 1_000_000));\nRowData row = converter.convert(record);","handlingStrategy":"validation","validationCode":"Object v = record.get(\"t\");\nif (!(v instanceof LocalTime) && !jodaSupported(v)) { throw new IllegalArgumentException(\"t has unexpected class: \" + v.getClass()); }","typeGuard":"boolean isSupportedTime(Object v) { return v instanceof LocalTime || v instanceof org.joda.time.LocalTime; }","tryCatchPattern":"try { return convertToTime(obj); } catch (IllegalArgumentException e) { return (int) toLocalTime(obj).get(ChronoField.MILLI_OF_DAY); }","preventionTips":["Align time-unit mapping properties with actual file encoding","Ensure joda-time dependency is present for legacy encodings","Check the 'Received:' class in the message to identify mapping mismatches quickly"],"tags":["flink","avro","time","type-mismatch"],"backgroundTag":"type-mismatch","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"}