apache/druid · error · IllegalArgumentException

Cannot get time from type[%s]

Error message

Cannot get time from type[%s]

What it means

TimeBoundaryResultValue.getDateTimeValue() converts the MIN_TIME/MAX_TIME entry into a joda DateTime. It supports DateTime, String (ISO), and Long (epoch millis); any other stored type is unsupported and throws IAE("Cannot get time from type[%s]").

Source

Thrown at processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryResultValue.java:115

           "value=" + value +
           '}';
  }

  @Nullable
  private DateTime getDateTimeValue(@Nullable Object val)
  {
    if (val == null) {
      return null;
    }

    if (val instanceof DateTime) {
      return (DateTime) val;
    } else if (val instanceof String) {
      return DateTimes.of((String) val);
    } else if (val instanceof Long) {
      return DateTimes.utc((Long) val);
    } else {
      throw new IAE("Cannot get time from type[%s]", val.getClass());
    }
  }
}

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Ensure the map value is a Long (epoch millis), String (ISO-8601), or DateTime before calling getMaxTime()/getMinTime()
  2. Normalize the value: DateTimes.utc(((Number) v).longValue()) for numeric types
  3. Fix the serializer/deserializer so timestamps round-trip as Long or String
  4. Pass the value through DateTimes.of/StringUtil conversion yourself before building the result

Example fix

// before
new TimeBoundaryResultValue(ImmutableMap.of(TimeBoundaryQuery.MAX_TIME, (int) millis)).getMaxTime(); // throws
// after
new TimeBoundaryResultValue(ImmutableMap.of(TimeBoundaryQuery.MAX_TIME, millis)).getMaxTime();
Defensive patterns

Strategy: validation

Validate before calling

Object v = map.get(TimeBoundaryQuery.MIN_TIME);
boolean safe = v instanceof DateTime || v instanceof String || v instanceof Long || v instanceof Integer;

Type guard

static boolean isSupportedTimeType(Object v) {
  return v instanceof DateTime || v instanceof String || v instanceof Number;
}

Try / catch

try { DateTime t = value.getMinTime(); } catch (IllegalArgumentException e) { log.warn("Unsupported time type in result", e); t = null; }

Prevention

When it happens

Trigger: A TimeBoundaryQuery result map whose MIN_TIME or MAX_TIME entry is neither DateTime, String, nor Long — e.g. an Integer, Date, byte[] from custom JSON deserialization, or a value put in the map by custom code.

Common situations: Custom storage/deserialization plugins producing Integer timestamps instead of Long, manually built result maps with java.util.Date, JSON numbers deserialized into non-Long types by non-standard mappers.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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