apache/beam · error · IllegalArgumentException

Unsupported timestamp unit: ${type.getUnit().name()}

Error message

Unsupported timestamp unit: ${type.getUnit().name()}

What it means

Thrown when converting an ArrowType.Timestamp whose time unit is not MILLISECOND, MICROSECOND, or NANOSECOND (milliseconds and microseconds map to FieldType.DATETIME; nanoseconds to Timestamp.NANOS). Only SECOND-unit timestamps fall through to this error.

Source

Thrown at sdks/java/extensions/arrow/src/main/java/org/apache/beam/sdk/extensions/arrow/ArrowConversion.java:267

                    throw new IllegalArgumentException(
                        "Type \'" + type.toString() + "\' not supported.");
                  }

                  @Override
                  public FieldType visit(ArrowType.Time type) {
                    throw new IllegalArgumentException(
                        "Type \'" + type.toString() + "\' not supported.");
                  }

                  @Override
                  public FieldType visit(ArrowType.Timestamp type) {
                    if (type.getUnit() == TimeUnit.MILLISECOND
                        || type.getUnit() == TimeUnit.MICROSECOND) {
                      return FieldType.DATETIME;
                    } else if (type.getUnit() == TimeUnit.NANOSECOND) {
                      return FieldType.logicalType(Timestamp.NANOS);
                    } else {
                      throw new IllegalArgumentException(
                          "Unsupported timestamp unit: " + type.getUnit().name());
                    }
                  }

                  @Override
                  public FieldType visit(ArrowType.Interval type) {
                    throw new IllegalArgumentException(
                        "Type \'" + type.toString() + "\' not supported.");
                  }

                  @Override
                  public FieldType visit(ArrowType.Duration type) {
                    throw new IllegalArgumentException(
                        "Type \'" + type.toString() + "\' not supported.");
                  }

                  @Override
                  public FieldType visit(ArrowType.ListView type) {

View on GitHub (pinned to 12126d8942)

Solutions

  1. Re-cast the timestamp column to MILLISECOND or MICROSECOND unit in the Arrow schema before conversion.
  2. Convert at the producer: multiply epoch seconds by 1000 and emit millisecond-precision timestamps.
  3. Patch the visitor to map SECOND to FieldType.DATETIME (seconds are representable in millis).

Example fix

// before
Field ts = Field.nullable("ts", new ArrowType.Timestamp(TimeUnit.SECOND, null));
// after
Field ts = Field.nullable("ts", new ArrowType.Timestamp(TimeUnit.MILLISECOND, null));
Defensive patterns

Strategy: validation

Validate before calling

for (Field f : schema.getFields()) {
  if (f.getType() instanceof ArrowType.Timestamp) {
    TimeUnit u = ((ArrowType.Timestamp) f.getType()).getUnit();
    if (u != TimeUnit.MILLISECOND && u != TimeUnit.MICROSECOND && u != TimeUnit.NANOSECOND) {
      throw new IllegalArgumentException(
          "Column " + f.getName() + " uses timestamp unit " + u + "; use MILLI/MICRO/NANO");
    }
  }
}

Type guard

boolean isConvertibleTimestamp(ArrowType t) {
  if (!(t instanceof ArrowType.Timestamp)) return false;
  TimeUnit u = ((ArrowType.Timestamp) t).getUnit();
  return u == TimeUnit.MILLISECOND || u == TimeUnit.MICROSECOND || u == TimeUnit.NANOSECOND;
}

Try / catch

try {
  Schema beamSchema = ArrowConversion.toBeamSchema(arrowSchema);
} catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Unsupported timestamp unit")) {
    arrowSchema = retimeTimestampUnits(arrowSchema); // SECOND -> MILLISECOND, then retry
  } else { throw e; }
}

Prevention

When it happens

Trigger: Converting an Arrow schema with a Timestamp column in TimeUnit.SECOND (e.g. unix-seconds timestamps) via ArrowConversion.

Common situations: Data produced by systems exporting epoch-seconds timestamps (common in C/Rust tooling and unix time storage) fed into a Beam ArrowIO pipeline.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/dd9ecef2ec463939. Report an issue: GitHub.