{"record":{"id":"84d9f76baaf2a796","repo":"apache/iceberg","slug":"unexpected-object-type-for-date-logical-type-rece","errorCode":null,"errorMessage":"Unexpected object type for DATE logical type. Received: ${object}","messagePattern":"Unexpected object type for DATE 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":267,"sourceCode":"        return TimestampData.fromEpochMillis(jodaConverter.convertTimestamp(object));\n      } else {\n        throw new IllegalArgumentException(\n            \"Unexpected object type for TIMESTAMP logical type. Received: \" + object);\n      }\n    }\n  }\n\n  private static int convertToDate(Object object) {\n    if (object instanceof Integer) {\n      return (Integer) object;\n    } else if (object instanceof LocalDate) {\n      return (int) ((LocalDate) object).toEpochDay();\n    } else {\n      JodaConverter jodaConverter = JodaConverter.getConverter();\n      if (jodaConverter != null) {\n        return (int) jodaConverter.convertDate(object);\n      } 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);","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/formats/avro/AvroToRowDataConverters.java#L249-L285","documentation":"convertToDate converts an Avro DATE logical-type value into an epoch-day int for Flink DATE. If the object is neither LocalDate nor a type the JodaConverter can handle, this IllegalArgumentException is thrown naming the actual object.","triggerScenarios":"Avro file stores a DATE field as a Java type outside the expected set (e.g. Integer days without the proper decoder, java.util.Date when Joda classes are absent on the classpath so JodaConverter returns null).","commonSituations":"Missing joda-time dependency on the classpath so legacy-encoded dates can't be bridged; Avro readers decoding DATE as a different type than the converter expects due to schema/mapping mismatch.","solutions":["Add the joda-time dependency if reading legacy (Joda-era) Avro files, so JodaConverter is available.","Align the DATE field encoding with the modern mapping (LocalDate / days as int) by rewriting the data files.","Inspect the 'Received:' value to identify the class and pre-convert it to LocalDate before conversion."],"exampleFix":"// before\n// file stores java.util.Date, joda-time not on classpath -> JodaConverter null\nRowData row = converter.convert(record); // throws\n// after\n// convert Date to LocalDate before reading, or add joda-time dependency\nrecord.put(\"d\", ((java.util.Date) record.get(\"d\")).toInstant().atZone(ZoneOffset.UTC).toLocalDate());","handlingStrategy":"validation","validationCode":"Object v = record.get(\"d\");\nif (!(v instanceof LocalDate) && !jodaSupported(v)) { throw new IllegalArgumentException(\"d has unexpected class: \" + v.getClass()); }","typeGuard":"boolean isSupportedDate(Object v) { return v instanceof LocalDate || v instanceof org.joda.time.LocalDate; }","tryCatchPattern":"try { return convertToDate(obj); } catch (IllegalArgumentException e) { return (int) toLocalDate(obj).toEpochDay(); }","preventionTips":["Include joda-time on the classpath when legacy Avro files may be read","Verify DATE field encoding (days since epoch as int/LocalDate) before reading","Rewrite legacy files to the modern mapping"],"tags":["flink","avro","date","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"}