{"record":{"id":"02e18655dfabfd0c","repo":"apache/beam","slug":"unexpected-timestamp-type-typename","errorCode":null,"errorMessage":"Unexpected timestamp type: {typeName}","messagePattern":"Unexpected timestamp 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":388,"sourceCode":"          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);\n        } else if (SqlTypeName.DATE.equals(typeName)) {\n          DateString dateString = literal.getValueAs(DateString.class);\n          datetime = LocalDateTime.of(LocalDate.parse(dateString.toString()), LocalTime.MIN);\n        } else if (SqlTypeName.TIMESTAMP.equals(typeName)) {\n          TimestampString timestampString = literal.getValueAs(TimestampString.class);\n          datetime = getLocalDateTime(timestampString.toString());\n        } else {\n          throw new IllegalArgumentException(\"Unexpected timestamp type: \" + literal.getTypeName());\n        }\n        return DateTimeUtil.microsFromTimestamp(datetime);\n      default:\n        throw new IllegalArgumentException(\n            String.format(\"Unsupported filter type in field '%s': %s\", field, type));\n    }\n  }\n\n  private static LocalDateTime getLocalDateTime(String value) {\n    LocalDateTime datetime;\n    for (DateTimeFormatter formatter : DATE_TIME_FORMATTERS) {\n      try {\n        datetime = LocalDateTime.parse(value, formatter);\n        return datetime;\n      } catch (DateTimeParseException ignored) {\n        // Ignore and try the next formatter.\n      }\n    }","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/FilterUtils.java#L370-L406","documentation":"When converting a literal for a TIMESTAMP-typed field, only DATE literals, TIMESTAMP literals, or string/UNKNOWN literals are accepted. Any other literal type throws this IllegalArgumentException listing the literal's SqlTypeName.","triggerScenarios":"Calling FilterUtils.convert with a predicate like \"ts = 1704067200\" (integer epoch literal) or a BOOLEAN/numeric literal against a TIMESTAMP field.","commonSituations":"Passing Unix epoch numbers instead of timestamp literals; filters generated with numeric timestamps; copying predicates from systems where timestamps are integers.","solutions":["Use a SQL timestamp literal: \"ts = TIMESTAMP '2024-01-01 00:00:00'\", or a quoted ISO string.","Convert epoch numbers to ISO-8601 strings before building the filter.","Check that the field is actually TIMESTAMP in the schema and the literal type matches."],"exampleFix":"// before\nExpression e = FilterUtils.convert(\"ts = 1704067200\", schema);\n// after\nExpression e = FilterUtils.convert(\"ts = TIMESTAMP '2024-01-01 00:00:00'\", schema);","handlingStrategy":"validation","validationCode":"checkArgument(LocalDateTime.parse(tsStr) != null, \"Timestamp literal must be ISO yyyy-MM-ddTHH:mm:ss\");\n// build filter as: \"ts = TIMESTAMP '\" + tsStr.replace('T', ' ') + \"'\"","typeGuard":null,"tryCatchPattern":"try { LocalDateTime.parse(userTs); } catch (DateTimeParseException e) { throw new IllegalArgumentException(\"Use ISO timestamp\", e); }","preventionTips":["Use TIMESTAMP '...' literals, never Unix epoch integers.","Convert epoch values to ISO strings before constructing filters.","Confirm the target column is TIMESTAMP in the schema."],"tags":["java","sql","timestamp","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"}