apache/druid · error · IllegalArgumentException

Format %s not supported

Error message

Format %s not supported

What it means

Granularity.getDateValues(filePath, formatter) parses datetime components out of a file path, but only supports the DEFAULT and HIVE path formats. Any other Formatter falls through to `throw new IAE("Format %s not supported", formatter)`. This is input validation over the supported path-pattern enum.

Source

Thrown at processing/src/main/java/org/apache/druid/java/util/common/granularity/Granularity.java:204

  public final Interval bucket(DateTime t)
  {
    DateTime start = bucketStart(t);
    return new Interval(start, increment(start));
  }

  // Used by the toDate implementations.
  final Integer[] getDateValues(String filePath, Formatter formatter)
  {
    Pattern pattern = DEFAULT_PATH_PATTERN;
    switch (formatter) {
      case DEFAULT:
      case LOWER_DEFAULT:
        break;
      case HIVE:
        pattern = HIVE_PATH_PATTERN;
        break;
      default:
        throw new IAE("Format %s not supported", formatter);
    }

    Matcher matcher = pattern.matcher(filePath);

    // The size is "7" b/c this array contains standard
    // datetime field values namely:
    // year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute,
    // and index 0 is unused.
    Integer[] vals = new Integer[7];
    if (matcher.matches()) {
      for (int i = 1; i <= matcher.groupCount(); i++) {
        vals[i] = (matcher.group(i) != null) ? Integer.parseInt(matcher.group(i)) : null;
      }
    }

    return vals;
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Pass Formatter.DEFAULT or Formatter.HIVE (LOWER_DEFAULT) when parsing dates from file paths
  2. Check the configured formatter value in your spec/JSON for typos or unsupported names
  3. Inspect the Formatter enum available in your Druid version and use one of its path-capable values
  4. If you need another path layout, pre-transform the path to DEFAULT/HIVE layout before calling, or implement custom parsing

Example fix

// before
granularity.toDate(path, Formatter.SOME_UNSUPPORTED_FORMAT);
// after
granularity.toDate(path, Formatter.DEFAULT); // or Formatter.HIVE for hive-style paths
Defensive patterns

Strategy: validation

Validate before calling

// Only DEFAULT (LOWER_DEFAULT) and HIVE are valid path formats
java.util.Set<Formatter> supported = java.util.EnumSet.of(Formatter.LOWER_DEFAULT, Formatter.HIVE);
if (formatter == null || !supported.contains(formatter)) {
  throw new IllegalArgumentException("Formatter must be LOWER_DEFAULT or HIVE, got: " + formatter);
}

Try / catch

try {
  granularity.toDate(path, formatter);
} catch (IllegalArgumentException e) {
  // 'Format %s not supported' — retry with Formatter.DEFAULT after logging the bad config
}

Prevention

When it happens

Trigger: Calling Granularity.getDateValues (or the public path-parsing entry point that reaches it) with a Formatter other than LOWER_DEFAULT or HIVE — e.g. a null or unrecognized formatter value.

Common situations: Typo or wrong enum in ingestion path spec; passing a formatter intended for a different API; deserialized configuration containing a formatter name not in the supported set; library versions where additional formats were added/removed.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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