{"record":{"id":"1ef126a2f7deba33","repo":"apache/druid","slug":"cannot-merge-columns-of-type-s-and-format-s-wi","errorCode":null,"errorMessage":"Cannot merge columns of type[%s] and format[%s] with type[%s] and format[%s]","messagePattern":"Cannot merge columns of type\\[(.+?)\\] and format\\[(.+?)\\] with type\\[(.+?)\\] and format\\[(.+?)\\]","errorType":"exception","errorClass":"ISE","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/column/StringDictionaryEncodedColumnFormat.java","lineNumber":125,"sourceCode":"    if (otherFormat == null) {\n      return this;\n    }\n\n    if (otherFormat instanceof StringDictionaryEncodedColumnFormat) {\n      final StringDictionaryEncodedColumnFormat other = (StringDictionaryEncodedColumnFormat) otherFormat;\n      return new StringDictionaryEncodedColumnFormat(\n          hasMultipleValues || other.hasMultipleValues,\n          hasNulls || other.hasNulls,\n          hasBitmapIndexes && other.hasBitmapIndexes,\n          hasSpatialIndexes || other.hasSpatialIndexes,\n          columnFormatSpec != null ? columnFormatSpec : other.columnFormatSpec\n      );\n    }\n\n    if (otherFormat instanceof CapabilitiesBasedFormat) {\n      final ColumnCapabilities otherCaps = otherFormat.toColumnCapabilities();\n      if (!otherCaps.is(ValueType.STRING)) {\n        throw new ISE(\n            \"Cannot merge columns of type[%s] and format[%s] with type[%s] and format[%s]\",\n            ColumnType.STRING,\n            this.getClass().getName(),\n            otherFormat.getLogicalType(),\n            otherFormat.getClass().getName()\n        );\n      }\n      return new StringDictionaryEncodedColumnFormat(\n          hasMultipleValues || otherCaps.hasMultipleValues().isMaybeTrue(),\n          hasNulls || otherCaps.hasNulls().isMaybeTrue(),\n          hasBitmapIndexes && otherCaps.hasBitmapIndexes(),\n          hasSpatialIndexes || otherCaps.hasSpatialIndexes(),\n          columnFormatSpec\n      );\n    }\n\n    throw new ISE(\n        \"Cannot merge columns of type[%s] and format[%s] and with [%s] and [%s]\",","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/column/StringDictionaryEncodedColumnFormat.java#L107-L143","documentation":"StringDictionaryEncodedColumnFormat.merge() combines two column format descriptors when merging/mixing segments. This ISE is thrown when the other format's column capabilities say the column is not a STRING — a string dictionary-encoded format can only merge with other string-typed formats. It is raised indirectly via combine/aggregate during segment merging or query processing.","triggerScenarios":"Calling merge() (directly or via combine/aggregate during segment merging) with an otherFormat whose ColumnCapabilities report a non-STRING ValueType, e.g. merging a dictionary-encoded string column descriptor with a numeric or complex column format.","commonSituations":"Merging segments whose schema for the same column diverged (one wrote it as string, another as long/complex); a buggy ingestion spec writing inconsistent types for one column across incremental persists.","solutions":["Re-ingest the affected segments so the column has a consistent STRING type everywhere","Fix the ingestion spec so the column type is identical across all segments being merged","Verify no segment-merge/compaction job is mixing columns of mismatched types"],"exampleFix":"// before\n// spec writes \"user_id\" as string in some segments, long in others, then compaction merges them -> ISE\n// after\n// normalize the column in the ingestion spec:\n\"metricsSpec\": { \"name\": \"user_id\", \"type\": \"string\" } // consistent everywhere before merging","handlingStrategy":"validation","validationCode":"if (!otherFormat.toColumnCapabilities().is(ValueType.STRING)) {\n  throw new IllegalStateException(\"Refusing merge: non-STRING column fed to string dictionary merge\");\n}","typeGuard":"boolean isStringFormat(ColumnFormat other) {\n  return other.toColumnCapabilities() != null && other.toColumnCapabilities().is(ValueType.STRING);\n}","tryCatchPattern":"try {\n  ColumnFormat merged = thisFormat.merge(otherFormat, caps);\n} catch (ISE e) {\n  LOG.warn(e, \"Format merge type mismatch; schedule re-ingestion of affected segments\");\n}","preventionTips":["Keep column types consistent in the ingestion spec across all segments","Run compaction only over segments with identical schemas","Check ColumnCapabilities before merge operations"],"tags":["java","segment-merge","column-format","type-mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}