apache/druid · error · ParseException

Could not transform value for __time.

Error message

Could not transform value for __time.

What it means

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.

Source

Thrown at processing/src/main/java/org/apache/druid/segment/transform/TransformedInputRow.java:64

    this.timestamp = readTimestampFromRow(row, transforms);
  }

  @Override
  public List<String> getDimensions()
  {
    return row.getDimensions();
  }

  static DateTime readTimestampFromRow(final InputRow row, final Map<String, RowFunction> transforms)
  {
    final RowFunction transform = transforms.get(ColumnHolder.TIME_COLUMN_NAME);
    final long ts;
    if (transform != null) {
      //noinspection ConstantConditions time column is never null
      final Number transformedVal = Rows.objectToNumber(ColumnHolder.TIME_COLUMN_NAME, transform.eval(row), true);
      if (transformedVal == null) {
        throw new ParseException(row.toString(), "Could not transform value for __time.");
      }
      ts = transformedVal.longValue();
    } else {
      ts = row.getTimestampFromEpoch();
    }
    return DateTimes.utc(ts);
  }

  @Override
  public long getTimestampFromEpoch()
  {
    return timestamp.getMillis();
  }

  @Override
  public DateTime getTimestamp()
  {
    return timestamp;

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Fix the transform expression to handle nulls, e.g. wrap in COALESCE/TIMESTAMP_TO_MILLIS with a default, or filter null rows before transform
  2. Verify the timestampSpec parses the timestamp correctly so the __time transform receives a valid value
  3. Add a filter/not-null check in the parse spec or use transform like "__time = timestamp_parse(x)" ensuring non-null output
  4. If rows should be dropped instead of failing, add a filter on the transformed expression in the ingestion spec

Example fix

// before
"transformSpec": { "transforms": [ { "name": "__time", "expression": "timestamp_shift(bad_ts, 'P1D')" } ] }
// after
"transformSpec": { "transforms": [ { "name": "__time", "expression": "COALESCE(timestamp_shift(bad_ts, 'P1D'), MILLIS_TO_TIMESTAMP(0))" } ] }
Defensive patterns

Strategy: validation

Validate before calling

// before submitting spec, check the transform never yields null
Object v = transform.eval(sampleRow);
if (v == null || !(v instanceof Number || v instanceof String && v.toString().matches("\\d+"))) {
  throw new IllegalArgumentException("__time transform can produce null/non-numeric");
}

Type guard

if (transformed == null || !(transformed instanceof Number)) { /* handle or drop row */ }

Try / catch

try { row.getTimestamp(); } catch (ParseException e) { log.warn("Row rejected: {}", e.getMessage()); /* skip/dead-letter row */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/6f259b1b5993a712. Report an issue: GitHub.