{"record":{"id":"51c47ac236a8d306","repo":"apache/druid","slug":"metric-names-differ-expected-s-found-s","errorCode":null,"errorMessage":"Metric names differ. Expected [%s] found [%s]","messagePattern":"Metric names differ\\. Expected \\[(.+?)\\] found \\[(.+?)\\]","errorType":"validation","errorClass":"SegmentValidationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/IndexIO.java","lineNumber":172,"sourceCode":"          \"Row count mismatch. Expected [%d] found [%d]\",\n          adapter1.getNumRows(),\n          adapter2.getNumRows()\n      );\n    }\n    {\n      final Set<String> dimNames1 = Sets.newHashSet(adapter1.getDimensionNames(true));\n      final Set<String> dimNames2 = Sets.newHashSet(adapter2.getDimensionNames(true));\n      if (!dimNames1.equals(dimNames2)) {\n        throw new SegmentValidationException(\n            \"Dimension names differ. Expected [%s] found [%s]\",\n            dimNames1,\n            dimNames2\n        );\n      }\n      final Set<String> metNames1 = Sets.newHashSet(adapter1.getMetricNames());\n      final Set<String> metNames2 = Sets.newHashSet(adapter2.getMetricNames());\n      if (!metNames1.equals(metNames2)) {\n        throw new SegmentValidationException(\"Metric names differ. Expected [%s] found [%s]\", metNames1, metNames2);\n      }\n    }\n    try (\n        final RowIterator it1 = adapter1.getRows();\n        final RowIterator it2 = adapter2.getRows()\n    ) {\n      long row = 0L;\n      while (it1.moveToNext()) {\n        if (!it2.moveToNext()) {\n          throw new SegmentValidationException(\"Unexpected end of second adapter\");\n        }\n        final RowPointer rp1 = it1.getPointer();\n        final RowPointer rp2 = it2.getPointer();\n        ++row;\n        if (rp1.getRowNum() != rp2.getRowNum()) {\n          throw new SegmentValidationException(\"Row number mismatch: [%d] vs [%d]\", rp1.getRowNum(), rp2.getRowNum());\n        }\n        try {","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/IndexIO.java#L154-L190","documentation":"IndexIO.validateTwoSegments also compares metric (aggregator) name sets between the two segment adapters. This SegmentValidationException is thrown when the metric name sets differ, indicating the segments have different aggregator columns.","triggerScenarios":"validateTwoSegments where adapter1.getMetricNames() and adapter2.getMetricNames() yield unequal sets — a metric present in one segment but missing in the other.","commonSituations":"Changing the aggregators list between ingestion runs; a metricsInSpec typo or renamed aggregator; compaction producing different metrics than the original segment; comparing segments from different datasources or specs.","solutions":["Compare the metric sets in the message and identify the missing/extra metric.","Make both ingestion/compaction specs declare the same aggregators and rebuild the divergent segment.","If a metric was intentionally added/renamed, validate against the updated reference segment, not the old one.","Check query-time metric availability (queries depending on the missing metric will fail) after fixing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Set<String> met1 = Sets.newHashSet(adapter1.getMetricNames());\nSet<String> met2 = Sets.newHashSet(adapter2.getMetricNames());\nif (!met1.equals(met2)) {\n  throw new IllegalStateException(\"Metric sets differ: \" + met1 + \" vs \" + met2);\n}","typeGuard":null,"tryCatchPattern":"try {\n  io.validateTwoSegments(adapter1, adapter2);\n} catch (SegmentValidationException e) {\n  if (e.getMessage().startsWith(\"Metric names differ\")) {\n    log.error(\"Aggregator mismatch between segments: %s\", e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Keep the aggregators list identical across ingestion/compaction runs of the same datasource.","Review aggregator renames before rebuilding segments.","Generate compaction specs from the original segment's metrics to avoid drift.","Validate metric sets yourself before row-level comparison for clearer errors."],"tags":["segment-validation","segments","metrics"],"backgroundTag":"schema-validation-failed","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"}