{"record":{"id":"74d8cb14b50ed37f","repo":"apache/iceberg","slug":"unsupported-type-type","errorCode":null,"errorMessage":"Unsupported type: + type","messagePattern":"Unsupported type: \\+ type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/transforms/TimeTransform.java","lineNumber":42,"sourceCode":"import org.apache.iceberg.expressions.UnboundPredicate;\nimport org.apache.iceberg.types.Type;\nimport org.apache.iceberg.util.SerializableFunction;\n\nabstract class TimeTransform<S> implements Transform<S, Integer> {\n  protected static <R> R fromSourceType(Type type, R dateResult, R microsResult, R nanosResult) {\n    switch (type.typeId()) {\n      case DATE:\n        if (dateResult != null) {\n          return dateResult;\n        }\n        break;\n      case TIMESTAMP:\n        return microsResult;\n      case TIMESTAMP_NANO:\n        return nanosResult;\n    }\n\n    throw new IllegalArgumentException(\"Unsupported type: \" + type);\n  }\n\n  protected abstract ChronoUnit granularity();\n\n  protected abstract Transform<S, Integer> toEnum(Type type);\n\n  @Override\n  public SerializableFunction<S, Integer> bind(Type type) {\n    return toEnum(type).bind(type);\n  }\n\n  @Override\n  public boolean preservesOrder() {\n    return true;\n  }\n\n  @Override\n  public boolean satisfiesOrderOf(Transform<?, ?> other) {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/transforms/TimeTransform.java#L24-L60","documentation":"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.","triggerScenarios":"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()).","commonSituations":"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.","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"],"exampleFix":"// before\nTransform<Integer, Integer> t = Transforms.day(Types.TimeType.get()); // IllegalArgumentException\n// after\nTypes.NestedField field = schema.findField(\"event_ts\");\nTransform<Integer, Integer> t = field.type() instanceof Types.TimestampType\n    ? Transforms.day(field.type())\n    : Transforms.identity();","handlingStrategy":"validation","validationCode":"boolean validTimeTransformSource(Type sourceType) {\n  return sourceType.typeId() == Type.TypeID.DATE\n      || sourceType.typeId() == Type.TypeID.TIMESTAMP\n      || sourceType.typeId() == Type.TypeID.TIMESTAMP_NANO;\n}\n// verify the partition field's source column type before Transforms.day(t)/year(t)/etc.","typeGuard":"if (!(type instanceof Types.DateType) && !(type instanceof Types.TimestampType)\n    && !(type instanceof Types.TimestampNanoType)) {\n  throw new IllegalArgumentException(\"Time transforms require a date or timestamp source: \" + type);\n}","tryCatchPattern":"try {\n  Transform<Integer, Integer> t = Transforms.day(sourceType);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported type\")) {\n    throw new IllegalArgumentException(\"day() needs a date/timestamp column, got \" + sourceType, e);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["java","transforms","type-mismatch","temporal"],"backgroundTag":"incompatible-source-type","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}