{"record":{"id":"9d7e4ca7d535e97b","repo":"apache/iceberg","slug":"unexpected-object-type-for-date-logical-type-rece-9d7e4c","errorCode":null,"errorMessage":"Unexpected object type for DATE logical type. Received: \" + object","messagePattern":"Unexpected object type for DATE 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":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.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/AvroToRowDataConverters.java#L249-L285","documentation":"convertToDate converts the Avro-decoded object for a DATE logical type into epoch-day int. It supports java.time.LocalDate and Joda-readable objects (when JodaConverter is available); anything else raises IllegalArgumentException(\"Unexpected object type for DATE logical type. Received: \" + object). It fires when the runtime object doesn't match the declared DATE logical type.","triggerScenarios":"An Avro field with date logical type decodes to an unexpected object (e.g. Integer millis because the schema declared int without the date logical type, or a String date), or Joda converter is unavailable for legacy Joda-encoded dates.","commonSituations":"Avro schema/actual data mismatch: producer writes plain int but consumer schema declares Avro 'date'; missing joda-time dependency; custom decoders bypassing logical-type conversion.","solutions":["Ensure the producer's Avro schema applies the 'date' logical type so the decoder yields LocalDate.","Add joda-time to the classpath if consuming legacy Joda-encoded data.","Check the printed object type in the message and align the Flink column type (e.g. INT for raw day counts)."],"exampleFix":"// before\n{ \"name\": \"d\", \"type\": \"int\" } // no logicalType\n// after\n{ \"name\": \"d\", \"type\": { \"type\": \"int\", \"logicalType\": \"date\" } }","handlingStrategy":"type-guard","validationCode":"if (!(avroObject instanceof LocalDate) && JodaConverter.getConverter() == null) { throw new IllegalStateException(\"DATE field decodes to \" + avroObject.getClass() + \" and Joda converter unavailable\"); }","typeGuard":"boolean isSupportedDateObject(Object o) { return o instanceof LocalDate || (isJodaDate(o) && JodaConverter.getConverter() != null); }","tryCatchPattern":"try { int day = convertToDate(avroObject); } catch (IllegalArgumentException e) { /* log object class, fix schema or converter */ }","preventionTips":["Ensure producer schemas apply the Avro 'date' logicalType.","Never assume plain ints carry date semantics; declare types explicitly.","Validate decoded object classes in a smoke test job."],"tags":["flink","avro","date","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"}