{"record":{"id":"da401e5024dcf2bb","repo":"apache/druid","slug":"dim-s-values-not-equal-expected-s-found-s","errorCode":null,"errorMessage":"Dim [%s] values not equal. Expected %s found %s","messagePattern":"Dim \\[(.+?)\\] values not equal\\. Expected (.+?) found (.+?)","errorType":"validation","errorClass":"SegmentValidationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/IndexIO.java","lineNumber":283,"sourceCode":"      final String dim2Name = dim2Names.get(i);\n\n      ColumnCapabilities capabilities1 = adapter1.getCapabilities(dim1Name);\n      ColumnCapabilities capabilities2 = adapter2.getCapabilities(dim2Name);\n      ColumnType dim1Type = capabilities1.toColumnType();\n      ColumnType dim2Type = capabilities2.toColumnType();\n      if (!Objects.equals(dim1Type, dim2Type)) {\n        throw new SegmentValidationException(\n            \"Dim [%s] types not equal. Expected %d found %d\",\n            dim1Name,\n            dim1Type,\n            dim2Type\n        );\n      }\n\n      Object vals1 = dims1.get(i);\n      Object vals2 = dims2.get(i);\n      if (isNullRow(vals1) ^ isNullRow(vals2)) {\n        throw notEqualValidationException(dim1Name, vals1, vals2);\n      }\n      boolean vals1IsList = vals1 instanceof List;\n      boolean vals2IsList = vals2 instanceof List;\n      if (vals1IsList ^ vals2IsList) {\n        if (vals1IsList) {\n          if (((List) vals1).size() != 1 || !Objects.equals(((List) vals1).get(0), vals2)) {\n            throw notEqualValidationException(dim1Name, vals1, vals2);\n          }\n        } else {\n          if (((List) vals2).size() != 1 || !Objects.equals(((List) vals2).get(0), vals1)) {\n            throw notEqualValidationException(dim1Name, vals1, vals2);\n          }\n        }\n      } else if (vals1 instanceof Object[]) {\n        if (!Arrays.deepEquals((Object[]) vals1, (Object[]) vals2)) {\n          throw notEqualValidationException(dim1Name, vals1, vals2);\n        }\n      } else {","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/IndexIO.java#L265-L301","documentation":"IndexIO.validateTwoSegments compares corresponding rows/columns of two segments and throws a ValidationException 'Dim [%s] values not equal. Expected %s found %s' when a dimension's null-ness differs between the two segments for the same row. Here exactly one of the two values is a null row (isNullRow XOR). This guard detects segment corruption or divergence between replicas/converted segments.","triggerScenarios":"Running validateTwoSegments (e.g. segment conversion validation, replacement validation) where at row i for dimension i, one segment holds a null row and the other holds a non-null value.","commonSituations":"Verifying segments after Druid version upgrades or index conversion; comparing replaced/historical segments; corrupted partial data written by a buggy ingestion run.","solutions":["Re-ingest or re-generate the segment from source data.","Compare against the correct counterpart segment; verify you validated the intended pair.","Check for segment corruption with the segment's metadata/hash and restore from deep storage."],"exampleFix":"// before\nindexIO.validateTwoSegments(expectedSegment, convertedSegment);\n// after\n// regenerate the mismatching segment instead of validating\nSegment fixed = segmentCreator.buildFromSource(sourceData);\nindexIO.validateTwoSegments(expectedSegment, fixed);","handlingStrategy":"validation","validationCode":"// pre-check null-ness parity before validation\nboolean nullParity = isNullRow(vals1) == isNullRow(vals2);\nif (!nullParity) { regenerateSegment(); }","typeGuard":null,"tryCatchPattern":"try { indexIO.validateTwoSegments(a, b); } catch (ValidationException e) { log.error(\"Segment mismatch: {}\", e.getMessage()); regenerateFromSource(); }","preventionTips":["Always validate segments against a trusted counterpart from the same ingestion run.","Restore suspicious segments from deep storage before validation.","Pin the same Druid version for segment conversion and validation."],"tags":["druid","segment-validation","data-integrity"],"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"}