{"record":{"id":"c9189fa65c0bed5a","repo":"apache/druid","slug":"table-is-too-large","errorCode":null,"errorMessage":"Table is too large","messagePattern":"Table is too large","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/join/table/IndexedTableDimensionSelector.java","lineNumber":157,"sourceCode":"\n  @Override\n  public void inspectRuntimeShape(RuntimeShapeInspector inspector)\n  {\n    inspector.visit(\"table\", table);\n    inspector.visit(\"extractionFn\", extractionFn);\n  }\n\n  /**\n   * Returns the value that {@link #getValueCardinality()} would return for a particular {@link IndexedTable}.\n   *\n   * The value will be one higher than {@link IndexedTable#numRows()}, to account for the possibility of phantom nulls.\n   *\n   * @throws IllegalArgumentException if the table's row count is {@link Integer#MAX_VALUE}\n   */\n  static int computeDimensionSelectorCardinality(final IndexedTable table)\n  {\n    if (table.numRows() == Integer.MAX_VALUE) {\n      throw new IllegalArgumentException(\"Table is too large\");\n    }\n\n    return table.numRows() + 1;\n  }\n}\n","sourceCodeStart":139,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/join/table/IndexedTableDimensionSelector.java#L139-L163","documentation":"Dimension selector cardinality is computed as numRows() + 1 (the +1 for null), so a table with exactly Integer.MAX_VALUE rows would overflow int. The library throws IllegalArgumentException to prevent silent integer overflow in cardinality math.","triggerScenarios":"Calling getValueCardinality() on an IndexedTableDimensionSelector whose backing IndexedTable has numRows() == Integer.MAX_VALUE (2147483647 rows).","commonSituations":"Extremely large broadcast/lookup tables joined in-memory; synthetic or stress tests sized to Integer.MAX_VALUE rows; misconfigured ingestion that inflates row counts.","solutions":["Reduce the table size below Integer.MAX_VALUE rows","Use a different join strategy that does not require an IndexedTable dimension selector (e.g. filter/subquery pushdown)","Split or partition the data so the join table is smaller"],"exampleFix":"// before\nif (table.numRows() >= Integer.MAX_VALUE) { /* shrink table */ }\n// after\nif (table.numRows() >= Integer.MAX_VALUE) {\n  throw new IllegalArgumentException(\"Table is too large\"); // existing guard; caller must shrink the table\n}","handlingStrategy":"validation","validationCode":"if (table.numRows() == Integer.MAX_VALUE) { throw new IllegalStateException(\"join table too large\"); }","typeGuard":null,"tryCatchPattern":"try { int card = selector.getValueCardinality(); } catch (IllegalArgumentException e) { /* fall back to unknown cardinality */ }","preventionTips":["Keep broadcast/join tables far below Integer.MAX_VALUE rows","Treat cardinality as optional and handle unknown gracefully"],"tags":["java","join","integer-overflow","cardinality"],"backgroundTag":"value-out-of-range","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"}