apache/druid · error · IllegalStateException

Partition column [ ] not found in RAC.

Error message

Partition column [%s] not found in RAC.

What it means

GlueingPartitioningOperator.isGlueingNeeded checks whether rows are already sorted by the partition columns by comparing the first and last row values in the RowsAndColumns holder. If any configured partition column is absent from the RAC it cannot validate the ordering and throws this ISE.

Solutions

  1. Verify every partition column exists in the query's row signature and segment columns before the window operator
  2. Fix the partition column name (check spelling/case) in the query or operator factory
  3. Ensure upstream operators (projections/transforms) do not drop columns needed for partitioning

Example fix

// before
OVER (PARTITION BY partCol ORDER BY ts) // partCol missing from segment
// after
OVER (PARTITION BY partitionKey ORDER BY ts) // column present in datasource
Defensive patterns

Strategy: validation

Validate before calling

for (String col : partitionColumns) {
  if (!rowSignature.getColumnNames().contains(col)) {
    throw new IllegalArgumentException("Partition column missing from segment signature: " + col);
  }
}

Type guard

boolean hasAllPartitionColumns(RowSignature sig, List<String> cols) {
  return cols.stream().allMatch(c -> sig.indexOf(c) >= 0);
}

Try / catch

try {
  windowQuery.run();
} catch (ISE e) {
  if (e.getMessage().startsWith("Partition column")) {
    throw new QueryPlanningException("Bad PARTITION BY column: " + e.getMessage());
  } else throw e;
}

Prevention

When it happens

Trigger: Running a window operator query whose partition columns list includes a column that does not exist in the incoming RowsAndColumns (e.g. a typo'd column name or a column dropped by an upstream operator/transform).

Common situations: Referencing a column that was filtered out or renamed by an earlier projection, misspelled PARTITION BY columns in window function SQL, or segments whose signatures don't include the partition key.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/08f2af4ced83ab74. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/operator/GlueingPartitioningOperator.java:241

      // If previousRac is null, just return the next partitioned RAC.
      currentIndex++;
      return new LimitedRowsAndColumns(rac, start, end);
    }

    /**
     * Determines whether glueing is needed between 2 RACs represented as a ConcatRowsAndColumns, by comparing a row belonging to each RAC.
     * We do this by comparing the first and last rows of the Concat RAC, as they would belong to the two respective RACs.
     * If the columns match, we can glue the 2 RACs and use the ConcatRAC.
     * @param rac A {@link ConcatRowsAndColumns containing 2 RACs}
     * @return true if gluing is needed, false otherwise.
     */
    private boolean isGlueingNeeded(ConcatRowsAndColumns rac)
    {
      for (String column : partitionColumns) {
        final Column theCol = rac.findColumn(column);
        if (theCol == null) {
          throw new ISE("Partition column [%s] not found in RAC.", column);
        }
        final ColumnAccessor accessor = theCol.toAccessor();
        int comparison = accessor.compareRows(0, rac.numRows() - 1);
        if (comparison != 0) {
          return false;
        }
      }
      return true;
    }

    private ConcatRowsAndColumns getConcatRacForFirstPartition(RowsAndColumns previousRac, RowsAndColumns firstPartitionOfCurrentRac)
    {
      if (previousRac == null) {
        return new ConcatRowsAndColumns(new ArrayList<>(Collections.singletonList(firstPartitionOfCurrentRac)));
      }
      return new ConcatRowsAndColumns(new ArrayList<>(Arrays.asList(previousRac, firstPartitionOfCurrentRac)));
    }
  }

View on GitHub (pinned to 9b90983fd2)