prestodb/presto · error · IllegalArgumentException
Unsupported state type combination: (%s, %s)
Error message
Unsupported state type combination: (%s, %s)
What it means
TwoNullableValueStateMapping.getStateSerializer selects an AccumulatorStateSerializer for aggregations over two nullable inputs based on the Java types of the two state types. The serializer factory only supports secondType whose Java type is Block or Slice; anything else (e.g. long, boolean, double) is unsupported and triggers an IllegalArgumentException before any type-specific branch runs.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/minmaxby/TwoNullableValueStateMapping.java:80
.put(ImmutableList.of(Block.class, Slice.class), BlockAndBlockPositionValueState.class)
.build();
}
public static Class<? extends AccumulatorState> getStateClass(Class<?> first, Class<?> second)
{
List<Class<?>> key = ImmutableList.of(first, second);
Class<? extends AccumulatorState> state = STATE_MAPPINGS.get(key);
checkArgument(state != null, "Unsupported state type combination: (%s, %s)", first.getName(), second.getName());
return state;
}
public static AccumulatorStateSerializer<?> getStateSerializer(Type firstType, Type secondType)
{
Class<?> firstJavaType = firstType.getJavaType();
Class<?> secondJavaType = secondType.getJavaType();
if (secondJavaType != Block.class && secondJavaType != Slice.class) {
throw new IllegalArgumentException(format("Unsupported state type combination: (%s, %s)", firstJavaType.getName(), secondJavaType.getName()));
}
if (firstJavaType == boolean.class) {
return new BooleanAndBlockPositionStateSerializer(firstType, secondType);
}
if (firstJavaType == long.class) {
return new LongAndBlockPositionStateSerializer(firstType, secondType);
}
if (firstJavaType == double.class) {
return new DoubleAndBlockPositionStateSerializer(firstType, secondType);
}
if (firstJavaType == Slice.class) {
return new SliceAndBlockPositionStateSerializer(firstType, secondType);
}
if (firstJavaType == Block.class) {
return new BlockAndBlockPositionStateSerializer(firstType, secondType);
}
throw new IllegalArgumentException(format("Unsupported state type combination: (%s, %s)", firstJavaType.getName(), secondJavaType.getName()));
}View on GitHub (pinned to 55bb57d202)
Solutions
- Ensure the second input to the aggregation is a complex (Block/Slice-backed) type, e.g. pass the key column as the second argument of min_by/max_by rather than a scalar state.
- Check argument order — swapping the two arguments may put a supported type in position two.
- If implementing a custom function, add a serializer branch or coerce the second type to a supported representation.
- Verify the aggregation function registration matches the connector's supported signatures.
Example fix
// before serializer = TwoNullableValueStateMapping.getStateSerializer(bigintType, bigintType); // unsupported second type // after serializer = TwoNullableValueStateMapping.getStateSerializer(bigintType, blockType); // second type must be Block/Slice-backed
Defensive patterns
Strategy: type-guard
Validate before calling
-- Only invoke the aggregation when the second input is a complex (array/map/row) type SELECT typeof(key_col) FROM t LIMIT 1; -- must be array/map/row, not bigint/boolean
Type guard
boolean isSupportedSecondType(Type secondType) {
Class<?> j = secondType.getJavaType();
return j == Block.class || j == Slice.class;
} Prevention
- Check argument order for two-nullable-input aggregations.
- Verify function signatures before registering custom aggregations with this state mapping.
- Document that secondType must be Block- or Slice-backed.
When it happens
Trigger: Invoking an aggregation built on TwoNullableValueStateMapping (e.g. variants of min_by/max_by with two nullable inputs) where the second type's getJavaType() is neither Block.class nor Slice.class.
Common situations: Registering/using a custom two-nullable-argument aggregation function with an unsupported second parameter type (a scalar like BIGINT or BOOLEAN as the second input); engine internals mismatching state serializers after a version upgrade.
Related errors
- TIMESTAMP precision must be in range [0, %d]: %d
- Expected exactly one parameter for VARCHAR
- VARCHAR length must be a number
- BIGQUERY_UNSUPPORTED_COLUMN_TYPE
- Unsupported java type %s
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/c4bf7f12fe8af60c.
Report an issue: GitHub.