{"record":{"id":"d368c33b8717d4d7","repo":"apache/beam","slug":"unexpected-date-type-typename","errorCode":null,"errorMessage":"Unexpected date type: {typeName}","messagePattern":"Unexpected date type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/FilterUtils.java","lineNumber":362,"sourceCode":"      case LONG:\n        return literal.getValueAs(Long.class);\n      case FLOAT:\n        return literal.getValueAs(Float.class);\n      case DOUBLE:\n        return literal.getValueAs(Double.class);\n      case DECIMAL:\n        return literal.getValueAs(BigDecimal.class);\n      case STRING:\n        return literal.getValueAs(String.class);\n      case DATE:\n        LocalDate date;\n        if (SqlTypeName.STRING_TYPES.contains(typeName) || SqlTypeName.UNKNOWN.equals(typeName)) {\n          date = LocalDate.parse(literal.getValueAs(String.class));\n        } else if (SqlTypeName.DATE.equals(typeName)) {\n          DateString dateValue = literal.getValueAs(DateString.class);\n          date = LocalDate.parse(dateValue.toString());\n        } else {\n          throw new IllegalArgumentException(\"Unexpected date type: \" + literal.getTypeName());\n        }\n        return DateTimeUtil.daysFromDate(date);\n      case TIME:\n        LocalTime time;\n        if (SqlTypeName.STRING_TYPES.contains(typeName) || SqlTypeName.UNKNOWN.equals(typeName)) {\n          time = LocalTime.parse(literal.getValueAs(String.class));\n        } else if (SqlTypeName.TIME.equals(typeName)) {\n          TimeString timeString = literal.getValueAs(TimeString.class);\n          time = LocalTime.parse(timeString.toString());\n        } else {\n          throw new IllegalArgumentException(\"Unexpected date type: \" + literal.getTypeName());\n        }\n        return DateTimeUtil.microsFromTime(time);\n      case TIMESTAMP:\n        LocalDateTime datetime;\n        if (SqlTypeName.STRING_TYPES.contains(typeName) || SqlTypeName.UNKNOWN.equals(typeName)) {\n          String value = literal.getValueAs(String.class);\n          datetime = getLocalDateTime(value);","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/FilterUtils.java#L344-L380","documentation":"When converting a literal for a DATE-typed field, FilterUtils accepts string literals or SQL DATE literals only. A literal of any other SQL type (e.g., INTEGER or TIMESTAMP) used in a date predicate throws this IllegalArgumentException (note the message says 'date type' even in the TIME branch's sibling case).","triggerScenarios":"Calling FilterUtils.convert with a predicate like \"date_col = 20240101\" (integer literal) or otherwise providing a literal whose SqlTypeName is neither a string type, UNKNOWN, nor DATE against a DATE field.","commonSituations":"Writing dates as bare numbers instead of quoted strings; passing epoch ints to date comparisons; dialect quirks where the literal parses as a different type than expected.","solutions":["Write the date as a quoted string or SQL DATE literal: \"date_col = '2024-01-01'\" or \"date_col = DATE '2024-01-01'\".","Ensure the string is ISO-8601 (yyyy-MM-dd) so LocalDate.parse succeeds.","Check the literal's inferred type by printing the parsed SqlNode before conversion."],"exampleFix":"// before\nExpression e = FilterUtils.convert(\"d = 20240101\", schema);\n// after\nExpression e = FilterUtils.convert(\"d = DATE '2024-01-01'\", schema);","handlingStrategy":"validation","validationCode":"checkArgument(java.time.LocalDate.parse(dateStr) != null, \"Date literal must be ISO yyyy-MM-dd string\");\n// build filter as: \"d = DATE '\" + dateStr + \"'\"","typeGuard":null,"tryCatchPattern":"try { LocalDate.parse(userDate); } catch (DateTimeParseException e) { throw new IllegalArgumentException(\"Use ISO yyyy-MM-dd\", e); }","preventionTips":["Always emit DATE literals as DATE 'yyyy-MM-dd' or quoted ISO strings.","Never pass raw epoch integers for date columns.","Validate date strings with LocalDate.parse before building filters."],"tags":["java","sql","date","type-mismatch","apache-beam","iceberg"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}