{"record":{"id":"bbf810eb603b5cd1","repo":"apache/druid","slug":"could-not-ingest-value-s-as-long-for-dimension","errorCode":null,"errorMessage":"Could not ingest value [%s] as long for dimension [%s]. A long column cannot have multiple values in the same row.","messagePattern":"Could not ingest value \\[(.+?)\\] as long for dimension \\[(.+?)\\]\\. A long column cannot have multiple values in the same row\\.","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java","lineNumber":422,"sourceCode":"        }\n        throw new ParseException((String) valObj, message);\n      }\n      return ret;\n    } else if (valObj instanceof List) {\n      final String message;\n      if (objectKey != null) {\n        message = StringUtils.nonStrictFormat(\n            \"Could not ingest value [%s] as long for dimension [%s]. A long column cannot have multiple values in the same row.\",\n            valObj,\n            objectKey\n        );\n      } else {\n        message = StringUtils.nonStrictFormat(\n            \"Could not ingest value [%s] as long. A long column cannot have multiple values in the same row.\",\n            valObj\n        );\n      }\n      throw new ParseException(\n          valObj.getClass().toString(),\n          message\n      );\n    } else {\n      final String message;\n      if (objectKey != null) {\n        message = StringUtils.nonStrictFormat(\n            \"Could not convert value [%s] to long for dimension [%s]. Invalid type: [%s]\",\n            valObj,\n            objectKey,\n            valObj.getClass()\n        );\n      } else {\n        message = StringUtils.nonStrictFormat(\n            valObj.getClass().toString(),\n            \"Could not convert value [%s] to long. Invalid type: [%s]\",\n            valObj,\n            valObj.getClass()","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java#L404-L440","documentation":"convertObjectToLong throws this ParseException when the value is a List: long columns are single-valued, so a multi-value (list) input cannot be converted to long. Druid rejects multi-value rows for numeric columns during ingestion.","triggerScenarios":"A row's value for a long column is a List (multi-value dimension from JSON/Kafka input), and convertObjectToLong is invoked; also hit by convertObjectToType dispatching to convertObjectToLong.","commonSituations":"Nested/array JSON fields mapped to a long column; flattened event data that occasionally contains multiple values (e.g. \"ids\": [1,2]); Kafka/JSON input with inconsistent cardinality per row.","solutions":["Flatten or unnest the array before ingestion (e.g. use an auto-deny/unfold, or a transform taking the first element).","Ensure the input spec declares the field as a multi-value string dimension instead of long if it's genuinely multi-valued.","Pre-process input so numeric columns are scalars (e.g. take element [0] or join).","Use a transform like \"CAST(json_query(...), 'LONG')\" or extract a single value deterministically."],"exampleFix":"// before: row has \"vals\": [10, 20] for long column vals\n// after: transform to take the first element\n\"transforms\": [{\"type\": \"expression\", \"name\": \"vals\", \"expression\": \"CAST(vals[0] AS LONG)\"}]","handlingStrategy":"validation","validationCode":"boolean isScalar(Object v) {\n  return v == null || !(v instanceof List);\n}","typeGuard":"Long firstAsLong(Object v) {\n  if (v instanceof List) {\n    List<?> l = (List<?>) v;\n    return l.isEmpty() ? null : asLong(l.get(0));\n  }\n  return asLong(v);\n}","tryCatchPattern":"try {\n  return DimensionHandlerUtils.convertObjectToLong(value, fieldName, objectKey);\n} catch (ParseException e) {\n  if (e.getMessage().contains(\"multiple values\")) {\n    log.warn(\"Dropping multi-valued row for long field [%s]\", fieldName);\n    return null;\n  }\n  throw e;\n}","preventionTips":["Ensure numeric columns receive scalar values only","Declare genuinely multi-valued fields as multi-value string dimensions","Use transforms to unnest arrays (take element or aggregate) before conversion","Validate JSON payload shape in producers"],"tags":["ingestion","multi-value","type-conversion"],"backgroundTag":"invalid-argument-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}