{"record":{"id":"f1df436f68b17914","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-long","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Long","messagePattern":"Unsupported convert (.+?) to Long","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":1032,"sourceCode":"        if (value instanceof String) {\n            return convertLong((String) value);\n        }\n        if (value instanceof Time) {\n            return convertLong((Time) value);\n        }\n        if (value instanceof LocalTime) {\n            return convertLong((LocalTime) value);\n        }\n        if (value instanceof Date) {\n            return convertLong((Date) value);\n        }\n        if (value instanceof LocalDate) {\n            return convertLong((LocalDate) value);\n        }\n        if (value instanceof LocalDateTime) {\n            return convertLong((LocalDateTime) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Long\");\n    }\n\n    default long convertLong(Number value) {\n        return value.longValue();\n    }\n\n    default long convertLong(String value) {\n        return Long.parseLong(value);\n    }\n\n    default long convertLong(Time value) {\n        return value.toLocalTime().toSecondOfDay();\n    }\n\n    default long convertLong(LocalTime value) {\n        return value.toSecondOfDay();\n    }","sourceCodeStart":1014,"sourceCodeEnd":1050,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L1014-L1050","documentation":"Thrown by BasicDataConverter.convertLong(Object value) when the value is neither LocalDate nor LocalDateTime (and not a Number/String handled by default branches). It is the typeDefine-less variant of error 102; the message reports the actual class that could not be converted to a long.","triggerScenarios":"Calling the convertLong(Object) overload with String, byte[], java.util.Date, Boolean or arbitrary objects while expecting a BIGINT-compatible value.","commonSituations":"Direct use of the convenience overload in custom code; schema drift where a timestamp column changed to BIGINT in the sink but the source still emits String/Date objects; raw deserialization feeding numeric columns.","solutions":["Convert the value to a Number, LocalDate or LocalDateTime before calling convertLong (e.g. Long.parseLong for numeric strings)","Fix the catalog/schema so the field type matches what the source actually produces","Override convertLong(Object) in a custom converter implementation to handle the reported class"],"exampleFix":"// before\nlong l = converter.convertLong(row.getField(0)); // String timestamp throws\n// after\nObject v = row.getField(0);\nlong l = (v instanceof String) ? Long.parseLong((String) v) : converter.convertLong(v);","handlingStrategy":"type-guard","validationCode":"Object v = row.getField(0);\nif (!(v instanceof Number) && !(v instanceof LocalDate) && !(v instanceof LocalDateTime)) {\n    throw new IllegalArgumentException(\"Value \" + v.getClass() + \" cannot be converted to long\");\n}","typeGuard":"static boolean isLongConvertible(Object v) {\n    return v instanceof Number || v instanceof LocalDate || v instanceof LocalDateTime;\n}","tryCatchPattern":"try {\n    l = converter.convertLong(value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Cannot convert {} to long\", value.getClass());\n    l = 0L;\n}","preventionTips":["Parse numeric strings before calling convertLong","Use typed overloads when the runtime type is known","Validate row field classes in a transform before the sink conversion stage"],"tags":["java","type-conversion","unsupported-operation"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}