{"record":{"id":"63cc255a6ab22cc6","repo":"apache/druid","slug":"keycolumns-s-must-all-be-contained-in-rowsignatu","errorCode":null,"errorMessage":"keyColumns[%s] must all be contained in rowSignature[%s]","messagePattern":"keyColumns\\[(.+?)\\] must all be contained in rowSignature\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/join/table/RowBasedIndexedTable.java","lineNumber":91,"sourceCode":"      final List<RowType> table,\n      final RowAdapter<RowType> rowAdapter,\n      final RowSignature rowSignature,\n      final Set<String> keyColumns,\n      final String version,\n      @Nullable\n      final byte[] cacheKey\n  )\n  {\n    this.table = table;\n    this.rowSignature = rowSignature;\n    this.columnFunctions =\n        rowSignature.getColumnNames().stream().map(rowAdapter::columnFunction).collect(Collectors.toList());\n    this.keyColumns = keyColumns;\n    this.version = version;\n    this.cacheKey = cacheKey;\n\n    if (!ImmutableSet.copyOf(rowSignature.getColumnNames()).containsAll(keyColumns)) {\n      throw new ISE(\n          \"keyColumns[%s] must all be contained in rowSignature[%s]\",\n          String.join(\", \", keyColumns),\n          rowSignature\n      );\n    }\n\n    indexes = new ArrayList<>(rowSignature.size());\n\n    for (int i = 0; i < rowSignature.size(); i++) {\n      final String column = rowSignature.getColumnName(i);\n      final Index m;\n\n      if (keyColumns.contains(column)) {\n        final ColumnType keyType =\n            rowSignature.getColumnType(column).orElse(IndexedTableJoinMatcher.DEFAULT_KEY_TYPE);\n\n        final RowBasedIndexBuilder builder = new RowBasedIndexBuilder(keyType);\n        final Function<RowType, Object> columnFunction = columnFunctions.get(i);","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/join/table/RowBasedIndexedTable.java#L73-L109","documentation":"Key columns must be present in the table's row signature since indexes are built from column functions derived from the signature. The RowBasedIndexedTable constructor validates that keyColumns ⊆ rowSignature column names and throws ISE otherwise.","triggerScenarios":"Constructing RowBasedIndexedTable (directly or via Builder) passing a keyColumns set containing a column name not in the RowSignature, e.g. a typo or casing mismatch ('UserID' vs 'userId').","commonSituations":"Typo in key column names; key columns defined for a different schema version; programmatic table construction where signature and keyColumns drift; case-sensitivity mistakes.","solutions":["Fix the keyColumns list to use exact column names from rowSignature","Verify case-sensitivity of column names (Druid columns are case-sensitive)","Derive key columns programmatically by checking rowSignature.getColumnNames() first","Align the signature with the key columns actually needed for the join"],"exampleFix":"// before\nnew RowBasedIndexedTable<>(adapter, signature, version, Set.of(\"User_Id\"), cacheKey);\n// after\n// signature has column \"userId\"\nnew RowBasedIndexedTable<>(adapter, signature, version, Set.of(\"userId\"), cacheKey);","handlingStrategy":"validation","validationCode":"Set<String> sigCols = ImmutableSet.copyOf(rowSignature.getColumnNames());\nif (!sigCols.containsAll(keyColumns)) { throw new IllegalArgumentException(\"key columns not in signature\"); }","typeGuard":null,"tryCatchPattern":"try { table = new RowBasedIndexedTable<>(...); } catch (ISE e) { /* log and fix keyColumns/signature */ }","preventionTips":["Derive key column names from the signature instead of hardcoding","Watch for case mismatches in column names"],"tags":["java","schema","key-columns","signature"],"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-14T11:17:12.474Z"}