{"record":{"id":"6f259b1b5993a712","repo":"apache/druid","slug":"could-not-transform-value-for-time","errorCode":null,"errorMessage":"Could not transform value for __time.","messagePattern":"Could not transform value for __time\\.","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/transform/TransformedInputRow.java","lineNumber":64,"sourceCode":"\n    this.timestamp = readTimestampFromRow(row, transforms);\n  }\n\n  @Override\n  public List<String> getDimensions()\n  {\n    return row.getDimensions();\n  }\n\n  static DateTime readTimestampFromRow(final InputRow row, final Map<String, RowFunction> transforms)\n  {\n    final RowFunction transform = transforms.get(ColumnHolder.TIME_COLUMN_NAME);\n    final long ts;\n    if (transform != null) {\n      //noinspection ConstantConditions time column is never null\n      final Number transformedVal = Rows.objectToNumber(ColumnHolder.TIME_COLUMN_NAME, transform.eval(row), true);\n      if (transformedVal == null) {\n        throw new ParseException(row.toString(), \"Could not transform value for __time.\");\n      }\n      ts = transformedVal.longValue();\n    } else {\n      ts = row.getTimestampFromEpoch();\n    }\n    return DateTimes.utc(ts);\n  }\n\n  @Override\n  public long getTimestampFromEpoch()\n  {\n    return timestamp.getMillis();\n  }\n\n  @Override\n  public DateTime getTimestamp()\n  {\n    return timestamp;","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/transform/TransformedInputRow.java#L46-L82","documentation":"During ingestion, a transform applied to the __time column produced a null numeric value, so Druid cannot derive the event timestamp. Rows.timeTransform's TransformedInputRow converts the __time transform's output to a Number; when Rows.objectToNumber cannot coerce the transformed value (or it is null), it throws ParseException to reject the row. This is a data/transform mismatch: the expression returned something not interpretable as a timestamp.","triggerScenarios":"An ingestion spec defines a transform on __time whose expression evaluates to null or a non-numeric (e.g. a string like 'not-a-date') for some rows; timestampSpec with a missing column plus a transform that yields null; transforming __time with CEIL/FLOOR of a null input.","commonSituations":"JSON ingestion where some records lack the timestamp field being transformed; a time math expression (e.g. 'timestamp_shift') fed a null parse result; migration of specs where the column renamed but the __time transform still references the old one.","solutions":["Fix the transform expression to handle nulls, e.g. wrap in COALESCE/TIMESTAMP_TO_MILLIS with a default, or filter null rows before transform","Verify the timestampSpec parses the timestamp correctly so the __time transform receives a valid value","Add a filter/not-null check in the parse spec or use transform like \"__time = timestamp_parse(x)\" ensuring non-null output","If rows should be dropped instead of failing, add a filter on the transformed expression in the ingestion spec"],"exampleFix":"// before\n\"transformSpec\": { \"transforms\": [ { \"name\": \"__time\", \"expression\": \"timestamp_shift(bad_ts, 'P1D')\" } ] }\n// after\n\"transformSpec\": { \"transforms\": [ { \"name\": \"__time\", \"expression\": \"COALESCE(timestamp_shift(bad_ts, 'P1D'), MILLIS_TO_TIMESTAMP(0))\" } ] }","handlingStrategy":"validation","validationCode":"// before submitting spec, check the transform never yields null\nObject v = transform.eval(sampleRow);\nif (v == null || !(v instanceof Number || v instanceof String && v.toString().matches(\"\\\\d+\"))) {\n  throw new IllegalArgumentException(\"__time transform can produce null/non-numeric\");\n}","typeGuard":"if (transformed == null || !(transformed instanceof Number)) { /* handle or drop row */ }","tryCatchPattern":"try { row.getTimestamp(); } catch (ParseException e) { log.warn(\"Row rejected: {}\", e.getMessage()); /* skip/dead-letter row */ }","preventionTips":["Wrap __time transforms in COALESCE with a sensible default timestamp","Test ingestion specs with samples containing missing/null timestamp fields","Keep timestampSpec and __time transforms referencing the same, existing column"],"tags":["ingestion","parse-exception","transform","null-value"],"backgroundTag":"invalid-argument-value","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"}