{"record":{"id":"24801b8d8d12e9ac","repo":"apache/druid","slug":"this-method-should-not-be-invoked-for-this-granula-24801b","errorCode":null,"errorMessage":"This method should not be invoked for this granularity type","messagePattern":"This method should not be invoked for this granularity type","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/granularity/NoneGranularity.java","lineNumber":42,"sourceCode":"import org.joda.time.format.DateTimeFormatter;\n\n/**\n * NoneGranularity does not bucket data\n */\npublic class NoneGranularity extends Granularity\n{\n  /**\n   * This constructor is public b/c it is serialized and deserialized\n   * based on type in GranularityModule\n   */\n  public NoneGranularity()\n  {\n  }\n\n  @Override\n  public DateTimeFormatter getFormatter(Formatter type)\n  {\n    throw new UnsupportedOperationException(\"This method should not be invoked for this granularity type\");\n  }\n\n  @Override\n  public long increment(long time)\n  {\n    return time + 1;\n  }\n\n  @Override\n  public DateTime increment(DateTime time)\n  {\n    return time.plus(1);\n  }\n\n  @Override\n  public long bucketStart(long time)\n  {\n    return time;","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/granularity/NoneGranularity.java#L24-L60","documentation":"NoneGranularity represents 'no' granularity (effectively millisecond-level, unbucketed), so there is no meaningful date formatter to produce. getFormatter() unconditionally throws UnsupportedOperationException to signal that formatting by this granularity type is not a supported operation.","triggerScenarios":"Calling NoneGranularity.getFormatter(Formatter.Type) — directly or via code paths that format timestamps per granularity, e.g. segment naming, result timestamp serialization, or input row timestamp parsing configured with granularity \"NONE\".","commonSituations":"Generic code that calls getFormatter() on any Granularity without special-casing NONE; misconfigured ingestion specs where granularity was set to none but timestamp formatting is required.","solutions":["Use a real granularity (e.g. PeriodGranularity or GranularityType-based) when you need timestamp formatting","Special-case NoneGranularity in your code: format timestamps with DateTimeFormatter directly instead of via the granularity","If you only need bucketing/truncation, note NoneGranularity.increment/truncate are no-ops and avoid the formatter path entirely"],"exampleFix":"// before\nDateTimeFormatter fmt = granularity.getFormatter(Formatter.Type.DEFAULT);\n// after\nDateTimeFormatter fmt = (granularity instanceof NoneGranularity)\n    ? ISODateTimeFormat.dateTime()\n    : granularity.getFormatter(Formatter.Type.DEFAULT);","handlingStrategy":"type-guard","validationCode":"if (GranularityType.NONE.equals(granularityType) || granularity instanceof NoneGranularity) { /* do not call getFormatter */ }","typeGuard":"boolean canFormat = !(granularity instanceof NoneGranularity);","tryCatchPattern":"try { fmt = granularity.getFormatter(type); } catch (UnsupportedOperationException e) { fmt = ISODateTimeFormat.dateTime(); }","preventionTips":["Special-case NONE granularity before any per-granularity formatting","Never configure NONE granularity where timestamp output formatting is required","Document that NONE means no bucketing and no formatting support"],"tags":["granularity","unsupported-operation","druid"],"backgroundTag":"unsupported-operation","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"}