{"record":{"id":"cef01cc758e1e05b","repo":"alibaba/DataX","slug":"failed-to-cast-s-to-double","errorCode":null,"errorMessage":"Failed to cast %s to Double","messagePattern":"Failed to cast (.+?) to Double","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"gdbreader/src/main/java/com/alibaba/datax/plugin/reader/gdbreader/mapping/ValueType.java","lineNumber":97,"sourceCode":"            }\n\n            return new LongColumn(v);\n        }\n\n        private static DoubleColumn doubleColumnMapper(Object o) {\n            double v;\n            if (o instanceof Integer) {\n                v = (double) (int) o;\n            } else if (o instanceof Long) {\n                v = (double) (long) o;\n            } else if (o instanceof Float) {\n                v = (double) (float) o;\n            } else if (o instanceof Double) {\n                v = (double) o;\n            } else if (o instanceof String) {\n                v = Double.valueOf((String) o);\n            } else {\n                throw new RuntimeException(\"Failed to cast \" + o.getClass() + \" to Double\");\n            }\n\n            return new DoubleColumn(v);\n        }\n\n        private static BoolColumn boolColumnMapper(Object o) {\n            boolean v;\n            if (o instanceof Integer) {\n                v = ((int) o != 0);\n            } else if (o instanceof Long) {\n                v = ((long) o != 0);\n            } else if (o instanceof Boolean) {\n                v = (boolean) o;\n            } else if (o instanceof String) {\n                v = Boolean.valueOf((String) o);\n            } else {\n                throw new RuntimeException(\"Failed to cast \" + o.getClass() + \" to Boolean\");\n            }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/gdbreader/src/main/java/com/alibaba/datax/plugin/reader/gdbreader/mapping/ValueType.java#L79-L115","documentation":"doubleColumnMapper(Object o) in gdbreader's ValueType accepts Integer, Long, Float, Double, and parseable String; anything else (Boolean, Date, byte[], custom types) falls to the RuntimeException naming the offending class. It is the reader-side conversion of a GDB property to a DataX DoubleColumn.","triggerScenarios":"Column declared 'double' in the gdbreader mapping while the actual property is Boolean or a complex/temporal type the mapper cannot widen. E.g. a boolean flag mapped to double, or a Date property returned by the Gremlin client as java.util.Date.","commonSituations":"Mapping config copy-paste declaring all numeric-ish columns 'double'; GDB storing dates as java.util.Date on the server side; property cardinality returning a list (List) when multi-value properties exist — a List hits the else branch.","solutions":["Match the mapping type to the real property type: booleans -> 'boolean', dates -> 'string'","Check the class name in the error message; if it is a List/collection, the property is multi-valued — flatten it in GDB or map a single-valued property","Use 'string' mapping to bypass numeric conversion for heterogeneous properties"],"exampleFix":"// before\n{\"columnName\": \"isActive\", \"Type\": \"double\"}\n// after\n{\"columnName\": \"isActive\", \"Type\": \"boolean\"}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean mapsToDouble(Object o) {\n    return o instanceof Integer || o instanceof Long || o instanceof Float\n        || o instanceof Double\n        || (o instanceof String && ((String) o).matches(\"-?\\\\d+(\\\\.\\\\d+)?\"));\n}","tryCatchPattern":"catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\" to Double\")) {\n        // offending class name is in the message; adjust column Type or pre-convert the value\n    }\n    throw e;\n}","preventionTips":["Declare 'double' only for confirmed numeric properties; use 'string' for dates/misc","Flatten multi-valued properties in GDB before reading, collections never map to Double"],"tags":["gdb","gremlin","type-mapping","datax"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}