apache/iceberg · error
Unsupported type: + type
Error message
Unsupported type: + type
What it means
TimeTransform.fromSourceType maps the source column type to the per-type transform result: only DATE, TIMESTAMP, and TIMESTAMP_NANO sources are valid for time-based transforms (year/month/day/hour). Given any other input type — e.g. instant() (timestamptz depending on version), time, or a non-temporal type — it throws IllegalArgumentException because the transform is undefined for that source type.
Source
Thrown at api/src/main/java/org/apache/iceberg/transforms/TimeTransform.java:42
import org.apache.iceberg.expressions.UnboundPredicate;
import org.apache.iceberg.types.Type;
import org.apache.iceberg.util.SerializableFunction;
abstract class TimeTransform<S> implements Transform<S, Integer> {
protected static <R> R fromSourceType(Type type, R dateResult, R microsResult, R nanosResult) {
switch (type.typeId()) {
case DATE:
if (dateResult != null) {
return dateResult;
}
break;
case TIMESTAMP:
return microsResult;
case TIMESTAMP_NANO:
return nanosResult;
}
throw new IllegalArgumentException("Unsupported type: " + type);
}
protected abstract ChronoUnit granularity();
protected abstract Transform<S, Integer> toEnum(Type type);
@Override
public SerializableFunction<S, Integer> bind(Type type) {
return toEnum(type).bind(type);
}
@Override
public boolean preservesOrder() {
return true;
}
@Override
public boolean satisfiesOrderOf(Transform<?, ?> other) {View on GitHub (pinned to 86d9c8fc54)
Solutions
- Check the source column's type before applying a time transform: only date and timestamp (with/without zone, depending on version) are valid
- Use the transform on a date or timestamp column in the partition spec, e.g. day(TimestampType.withoutZone()) not day(TimeType.get())
- If the field type can vary, branch: use Identity or another transform for non-temporal types
Example fix
// before
Transform<Integer, Integer> t = Transforms.day(Types.TimeType.get()); // IllegalArgumentException
// after
Types.NestedField field = schema.findField("event_ts");
Transform<Integer, Integer> t = field.type() instanceof Types.TimestampType
? Transforms.day(field.type())
: Transforms.identity(); Defensive patterns
Strategy: validation
Validate before calling
boolean validTimeTransformSource(Type sourceType) {
return sourceType.typeId() == Type.TypeID.DATE
|| sourceType.typeId() == Type.TypeID.TIMESTAMP
|| sourceType.typeId() == Type.TypeID.TIMESTAMP_NANO;
}
// verify the partition field's source column type before Transforms.day(t)/year(t)/etc. Type guard
if (!(type instanceof Types.DateType) && !(type instanceof Types.TimestampType)
&& !(type instanceof Types.TimestampNanoType)) {
throw new IllegalArgumentException("Time transforms require a date or timestamp source: " + type);
} Try / catch
try {
Transform<Integer, Integer> t = Transforms.day(sourceType);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unsupported type")) {
throw new IllegalArgumentException("day() needs a date/timestamp column, got " + sourceType, e);
}
throw e;
} Prevention
- Check the partition field's source column type in the schema before choosing a temporal transform
- Don't apply year/month/day/hour to time, string, or numeric columns — use identity/truncate/bucket instead
- When generically translating specs, branch on source type rather than assuming all transforms apply
When it happens
Trigger: Calling Transforms.year(t)/month(t)/day(t)/hour(t) (or toEnum) with a Type that is not DATE, TIMESTAMP, or TIMESTAMP_NANO — for example day(Types.TimeType.get()), day(Types.StringType.get()), or on some versions day(TimestampType.withZone()).
Common situations: Generic schema-translation code that blindly applies the same transform to whatever source type a partition field references; specs written against different Iceberg versions where timestamptz handling changed; typos where a time-type column is partitioned by day instead of a timestamp.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Cannot create expression literal from %s: %s
- Cannot bucket by type:
- hash(value) is not supported on the base Bucket class
- Unsupported time unit:
- Unsupported binary type: + value.getClass()
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/74d8cb14b50ed37f.
Report an issue: GitHub.