{"record":{"id":"413d86e337fa6a59","repo":"apache/druid","slug":"could-not-transform-value-for-s-reason-s","errorCode":null,"errorMessage":"Could not transform value for %s reason: %s","messagePattern":"Could not transform value for (.+?) reason: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/transform/ExpressionTransform.java","lineNumber":116,"sourceCode":"  static class ExpressionRowFunction implements RowFunction\n  {\n    private final String name;\n    private final Expr expr;\n\n    ExpressionRowFunction(final String name, final Expr expr)\n    {\n      this.name = name;\n      this.expr = expr;\n    }\n\n    @Override\n    public Object eval(final Row row)\n    {\n      try {\n        return expr.eval(InputBindings.forRow(row)).value();\n      }\n      catch (Throwable t) {\n        throw new ISE(t, \"Could not transform value for %s reason: %s\", name, t.getMessage());\n      }\n    }\n\n    @Override\n    public List<String> evalDimension(Row row)\n    {\n      try {\n        return Rows.objectToStrings(expr.eval(InputBindings.forRow(row)).value());\n      }\n      catch (Throwable t) {\n        throw new ISE(t, \"Could not transform dimension value for %s reason: %s\", name, t.getMessage());\n      }\n    }\n  }\n\n  @Override\n  public boolean equals(final Object o)\n  {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/transform/ExpressionTransform.java#L98-L134","documentation":"ExpressionTransform.eval evaluates the Druid expression against a row's input bindings and wraps ANY Throwable (syntax error at plan time is separate; here it is evaluation failure) in this ISE naming the transform and the underlying message. It means the transform expression failed while computing a value for this row during ingestion or query-time transforms.","triggerScenarios":"Calling ExpressionTransform.eval(row) when the underlying expression evaluation throws — e.g. arithmetic on null/missing columns, division by zero, type errors in functions, or malformed expression logic that only fails for certain row values.","commonSituations":"Transform expressions referencing missing columns; regex_replace or timestampParse given unexpected row values; divide-by-zero in numeric transforms; NaN/empty string inputs to math functions during ingestion with transforms configured in the ioConfig.","solutions":["Inspect the nested cause message and fix the expression (guard nulls, validate inputs) in your transforms spec.","Wrap risky sub-expressions in functions that handle nulls (e.g. NVL, TRY expressions where available) or use 'nullIf' patterns to avoid division by zero.","Verify referenced columns exist in the input data and check a sample of input records for unexpected values (nulls, empty strings, bad formats).","Test the expression standalone with Druid's expression evaluation (e.g. via a small ingestion spec or EXPLAIN /表达式 eval in tests) before full ingestion."],"exampleFix":"// before\n\"transformSpec\": { \"transforms\": [{ \"name\": \"ratio\", \"expression\": \"a / b\" }] }\n// after\n\"transformSpec\": { \"transforms\": [{ \"name\": \"ratio\", \"expression\": \"a / (b + 0.0 == 0 ? null : b)\" }] }","handlingStrategy":"try-catch","validationCode":"// validate expression before submitting ingestion:\n// use Druid's built-in expression parser/validator or EXPLAIN on a query using the same expression,\n// and null-guard inputs: expression should tolerate null columns.","typeGuard":null,"tryCatchPattern":"try {\n    Object value = transform.eval(row);\n} catch (ISE e) {\n    log.warn(\"Transform '{}' failed for row: {}\", transform.getName(), e.getMessage(), e.getCause());\n    metrics.incrementTransformFailures(transform.getName());\n    return null; // or route row to a rejection path\n}","preventionTips":["Null-guard columns in transform expressions (use coalesce/nvl).","Avoid division expressions without zero checks.","Test transforms against a sample of real input data before full ingestion.","Log the cause chain to identify the exact failing sub-expression."],"tags":["druid","ingestion","expression","transform"],"backgroundTag":"expression-evaluation-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}