apache/druid · error · IllegalStateException

Unsupported unknown value type

Error message

Unsupported unknown value type

What it means

ExpressionType.fromColumnTypeStrict() converts a Druid column type signature into an expression type and explicitly does not allow null input: the expression system needs a concrete type to plan evaluation. A null TypeSignature<ValueType> ('unknown' type) is rejected with IllegalStateException. The non-strict variant fromColumnType() returns null instead, so this error signals a code path that requires a known column type but was handed an unknown one.

Source

Thrown at processing/src/main/java/org/apache/druid/math/expr/ExpressionType.java:125

        case COMPLEX:
          return elementType;
      }
    }
    return elementType;
  }


  /**
   * The expression system does not distinguish between {@link ValueType#FLOAT} and {@link ValueType#DOUBLE}, so,
   * this method will convert {@link ValueType#FLOAT} to {@link #DOUBLE}. Null values are not allowed in this method,
   * and will result in an {@link IllegalStateException}
   *
   * @throws IllegalStateException
   */
  public static ExpressionType fromColumnTypeStrict(@Nullable TypeSignature<ValueType> valueType)
  {
    if (valueType == null) {
      throw new IllegalStateException("Unsupported unknown value type");
    }
    switch (valueType.getType()) {
      case LONG:
        return LONG;
      case FLOAT:
      case DOUBLE:
        return DOUBLE;
      case STRING:
        return STRING;
      case ARRAY:
        switch (valueType.getElementType().getType()) {
          case LONG:
            return LONG_ARRAY;
          case FLOAT:
          case DOUBLE:
            return DOUBLE_ARRAY;
          case STRING:
            return STRING_ARRAY;

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Use ExpressionType.fromColumnType() instead if an unknown type is acceptable (it returns null rather than throwing).
  2. Guard the input before calling: check valueType != null (or resolve the actual column type from the RowSignature) before calling fromColumnTypeStrict.
  3. Fix the upstream source of the unknown type: ensure the column is declared in the RowSignature/datasource schema so its TypeSignature is resolved.
  4. Catch IllegalStateException at the call site and fall back to a default expression type if a default makes sense.

Example fix

// before
ExpressionType exprType = ExpressionType.fromColumnTypeStrict(signature);
// after
ExpressionType exprType = signature == null
    ? ExpressionType.STRING // or handle explicitly
    : ExpressionType.fromColumnTypeStrict(signature);
Defensive patterns

Strategy: validation

Validate before calling

if (valueType == null) {
  // resolve or default before calling
  valueType = rowSignature.getColumnSignature(columnName); // must be non-null
}
ExpressionType t = ExpressionType.fromColumnTypeStrict(valueType);

Type guard

boolean hasKnownType(TypeSignature<ValueType> sig) { return sig != null; }

Try / catch

try {
  ExpressionType t = ExpressionType.fromColumnTypeStrict(sig);
} catch (IllegalStateException e) {
  ExpressionType t = ExpressionType.fromColumnType(sig); // null-tolerant fallback
}

Prevention

When it happens

Trigger: Calling ExpressionType.fromColumnTypeStrict(null), or passing a column whose TypeSignature is unknown/null — e.g. resolving expression output types for a column that has no declared type (undefined/unknown columns in a segment or subquery).

Common situations: Querying expressions against segments or datasources where a column's type cannot be determined (missing column, unknown complex type, or inline/lookup input lacking type info); extension code that calls fromColumnTypeStrict instead of the null-tolerant fromColumnType.

Related errors


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