apache/druid · error · IllegalStateException
Cannot call makeDimensionSelector on field of type
Error message
Cannot call makeDimensionSelector on field of type [%s]
What it means
StringFieldReader.makeDimensionSelector supports reading string fields either as single strings or as string arrays (depending on how the field was written). When makeDimensionSelector is invoked with asArray=true on a field written as plain STRING (not STRING_ARRAY), the reader cannot produce an array selector and throws ISE. This is a mismatch between the column's declared/read type and the field's physical encoding in the frame.
Solutions
- Ensure frames are re-written after column type changes so the physical encoding matches the declared type.
- Request the selector with asArray=false when the field is a plain string.
- Verify ColumnCapabilities/type metadata on the frame column agrees with the frame's field kind.
Defensive patterns
Strategy: type-guard
Validate before calling
// Java: match asArray to the frame field's actual kind boolean wantArray = columnCapabilities.getType().isArray(); selector = fieldReader.makeDimensionSelector(memory, ptr, extractionFn, wantArray);
Type guard
// Only request array selectors when the column is truly array-typed
boolean asArray = capabilities.getType().equals(ColumnType.STRING_ARRAY)
&& !capabilities.getType().equals(ColumnType.STRING); Prevention
- Rewrite frames after column type changes so encoding matches declared schema.
- Verify frame column capabilities against physical field kind before selector creation.
When it happens
Trigger: Requesting a dimension selector with asArray=true from a column cursor backed by a frame whose string field was written in non-array mode; a type-adapter or cursor layer advertising STRING_ARRAY while the frame stores plain strings.
Common situations: Query planner assumes a column is an array (schema says STRING_ARRAY) but the frame was produced when the column was STRING; using frame-based cursors across segments whose schema changed between versions.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- attempt to get boolean[] null vector from string[] only…
- attempt to get double[] from string[] only scalar binding
- attempt to get long[] from string[] only scalar binding
- Cannot cast [ ] to [ ] (Types.InvalidCastException from…
- Cannot convert object to double
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/804f1bb1ceae577a.
Report an issue: GitHub.
Appendix: source
Thrown at processing/src/main/java/org/apache/druid/frame/field/StringFieldReader.java:116
{
this.asArray = asArray;
}
@Override
public ColumnValueSelector<?> makeColumnValueSelector(Memory memory, ReadableFieldPointer fieldPointer)
{
return new Selector(memory, fieldPointer, null, asArray);
}
@Override
public DimensionSelector makeDimensionSelector(
Memory memory,
ReadableFieldPointer fieldPointer,
@Nullable ExtractionFn extractionFn
)
{
if (asArray) {
throw new ISE("Cannot call makeDimensionSelector on field of type [%s]", ColumnType.STRING_ARRAY);
}
return new Selector(memory, fieldPointer, extractionFn, false);
}
@Override
public boolean isNull(Memory memory, long position)
{
final byte firstByte = memory.getByte(position);
if (firstByte == StringFieldWriter.NULL_ROW) {
return true;
} else if (!asArray) {
return firstByte == StringFieldWriter.NULL_BYTE
&& memory.getByte(position + 1) == StringFieldWriter.VALUE_TERMINATOR
&& memory.getByte(position + 2) == StringFieldWriter.ROW_TERMINATOR;
} else {
return false;View on GitHub (pinned to 9b90983fd2)