{"record":{"id":"96921d53d6107f7b","repo":"apache/hadoop","slug":"child-key-classes-fail-to-agree-96921d","errorCode":null,"errorMessage":"Child key classes fail to agree","messagePattern":"Child key classes fail to agree","errorType":"exception","errorClass":"ClassCastException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/join/CompositeRecordReader.java","lineNumber":123,"sourceCode":"        // get keyclass\n        if (keyclass == null) {\n          keyclass = kids[i].createKey().getClass().\n            asSubclass(WritableComparable.class);\n        }\n        // create priority queue\n        if (null == q) {\n          cmp = WritableComparator.get(keyclass, conf);\n          q = new PriorityQueue<ComposableRecordReader<K,?>>(3,\n                new Comparator<ComposableRecordReader<K,?>>() {\n                  public int compare(ComposableRecordReader<K,?> o1,\n                                     ComposableRecordReader<K,?> o2) {\n                    return cmp.compare(o1.key(), o2.key());\n                  }\n                });\n        }\n        // Explicit check for key class agreement\n        if (!keyclass.equals(kids[i].key().getClass())) {\n          throw new ClassCastException(\"Child key classes fail to agree\");\n        }\n        \n        // add the kid to priority queue if it has any elements\n        if (kids[i].hasNext()) {\n          q.add(kids[i]);\n        }\n      }\n    }\n  }\n\n  /**\n   * Return the position in the collector this class occupies.\n   */\n  public int id() {\n    return id;\n  }\n\n  /**","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/join/CompositeRecordReader.java#L105-L141","documentation":"Error \"Child key classes fail to agree\" thrown in apache/hadoop.","triggerScenarios":"Thrown by CompositeRecordReader when the child record readers in a join produce keys of different WritableComparable classes that cannot be compared to each other. Ensure all joined streams emit keys of the same type (or compatible join comparators).","commonSituations":"Joining inputs whose formats emit Text keys in one stream and IntWritable in another; mixed custom key classes.","solutions":["Make all child RecordReaders emit the same key class: align the InputFormats so every joined stream produces keys of one WritableComparable type.","If key types differ intentionally, wrap them in a common type (e.g. TupleWritable or a tagged union) before the join."],"exampleFix":"// use formats that both emit Text keys, e.g. KeyValueTextInputFormat for all joined paths","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}