apache/iceberg · error · UnsupportedOperationException

Day transform is not supported

Error message

Day transform is not supported

What it means

PartitionSpecVisitor's default day() methods throw UnsupportedOperationException because the visitor implementation did not override the day-transform hook. PartitionSpecVisitor.visit detects day transforms (Dates.DAY, Timestamps.MICROS_TO_DAY/NANOS_TO_DAY, Days) and routes the field to day(); implementations covering only identity/bucket/truncate (or other subsets) hit this default and fail fast rather than producing an incorrect partition-field translation.

Source

Thrown at api/src/main/java/org/apache/iceberg/transforms/PartitionSpecVisitor.java:73

  default T year(String sourceName, int sourceId) {
    throw new UnsupportedOperationException("Year transform is not supported");
  }

  default T month(int fieldId, String sourceName, int sourceId) {
    return month(sourceName, sourceId);
  }

  default T month(String sourceName, int sourceId) {
    throw new UnsupportedOperationException("Month transform is not supported");
  }

  default T day(int fieldId, String sourceName, int sourceId) {
    return day(sourceName, sourceId);
  }

  default T day(String sourceName, int sourceId) {
    throw new UnsupportedOperationException("Day transform is not supported");
  }

  default T hour(int fieldId, String sourceName, int sourceId) {
    return hour(sourceName, sourceId);
  }

  default T hour(String sourceName, int sourceId) {
    throw new UnsupportedOperationException("Hour transform is not supported");
  }

  default T alwaysNull(int fieldId, String sourceName, int sourceId) {
    throw new UnsupportedOperationException("Void transform is not supported");
  }

  default T unknown(int fieldId, String sourceName, int sourceId, String transform) {
    throw new UnsupportedOperationException(
        String.format("Unknown transform %s is not supported", transform));
  }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Override day(int fieldId, String sourceName, int sourceId) in your visitor implementation to handle the day transform
  2. Inspect table.spec().partitionType() before visiting to enumerate which transforms must be supported
  3. If day partitioning is out of scope, override day() to fail with a domain-specific message naming the table/spec

Example fix

// before
visitor without day override -> UnsupportedOperationException
// after
@Override
public String day(int fieldId, String sourceName, int sourceId) {
  return "days(" + sourceName + ")";
}
Defensive patterns

Strategy: validation

Validate before calling

boolean hasDayTransform(PartitionSpec spec) {
  return spec.fields().stream().anyMatch(f -> f.transform() instanceof Days
      || f.transform() == Dates.DAY || f.transform() == Timestamps.MICROS_TO_DAY);
}
// gate PartitionSpecVisitor.visit on this check

Type guard

if (field.transform() instanceof Days) {
  // handle day transform explicitly instead of falling through to the throwing default
}

Try / catch

try {
  PartitionSpecVisitor.visit(spec, visitor);
} catch (UnsupportedOperationException e) {
  throw new UnsupportedOperationException(
      "Table " + table.name() + " uses a day partition transform the visitor cannot map", e);
}

Prevention

When it happens

Trigger: PartitionSpecVisitor.visit on a table with a day(ts_col) or day(date_col) partition field where the concrete visitor has no day(int, String, int) or day(String, int) override.

Common situations: Very common in real deployments since day partitioning is one of the most widely used strategies: custom Hive/JDBC/Nessie catalog translators or metadata mappers that predate day-transform support, run against long-lived tables partitioned by day.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/0b554323d4026a2e. Report an issue: GitHub.