{"record":{"id":"fde343bd2dbf31f6","repo":"apache/iceberg","slug":"unexpected-object-type-for-date-logical-type-rece-fde343","errorCode":null,"errorMessage":"Unexpected object type for DATE logical type. Received: ","messagePattern":"Unexpected object type for DATE logical type\\. Received: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/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/v2.3/flink/src/main/java/org/apache/iceberg/flink/formats/avro/AvroToRowDataConverters.java#L249-L285","documentation":"convertToDate throws IllegalArgumentException when the object delivered for an Avro DATE logical type is neither java.time.LocalDate nor a Joda-convertible object (or Joda-Time is unavailable). The expected epoch-day conversion cannot be performed.","triggerScenarios":"Avro datum for a date field is a java.util.Date, Integer-epoch-days, ChronoLocalDate subclass, or other unexpected class; Joda converter absent for legacy Joda Date objects.","commonSituations":"Reading Avro files written by tools emitting non-java.time date representations; missing Joda-Time dependency when data uses Joda LocalDate.","solutions":["Ensure the upstream Avro encoding decodes to java.time.LocalDate","Add joda-time to the classpath if the producer wrote Joda date objects","Convert the object to LocalDate/epochDay yourself before invoking the converter"],"exampleFix":"// before\nint day = convertToDate(javaUtilDate); // throws\n// after\nint day = convertToDate(new LocalDate(javaUtilDate.getTime()).toEpochDay());","handlingStrategy":"type-guard","validationCode":"if (!(object instanceof LocalDate) && !isJodaDate(object)) { throw new IllegalArgumentException(\"Expected LocalDate for DATE field, got \" + object.getClass()); }","typeGuard":"boolean isDateDatum(Object o) { return o instanceof LocalDate || o instanceof org.joda.time.LocalDate; }","tryCatchPattern":"try { return convertToDate(object); } catch (IllegalArgumentException e) { log.error(\"Bad DATE datum class: {}\", object.getClass()); throw e; }","preventionTips":["Ensure Avro date logical types decode to java.time.LocalDate","Add joda-time when consuming legacy-encoded files","Validate date fields in a smoke-test read before production"],"tags":["flink","avro","date","type-mismatch","joda"],"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"}