apache/beam · error · IllegalArgumentException

Unsupported timestamp value type: %s

Error message

Unsupported timestamp value type: %s

What it means

The TIMESTAMP converter only accepts java.time.Instant, org.joda.time.Instant, and (per surrounding code) Long millis and String forms. A value of any other Java type in a TIMESTAMP field triggers this IllegalArgumentException naming the actual class.

Source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/TableRowToStorageApiProto.java:1666

        && schemaInformation.getTimestampPrecision() == PICOSECOND_PRECISION) {

      long seconds;
      long picoseconds;

      if (value instanceof String) {
        TimestampPicos parsed = TimestampPicos.fromString((String) value);
        seconds = parsed.seconds;
        picoseconds = parsed.picoseconds;

      } else if (value instanceof Instant || value instanceof org.joda.time.Instant) {
        Instant timestamp =
            value instanceof Instant
                ? (Instant) value
                : Instant.ofEpochMilli(((org.joda.time.Instant) value).getMillis());
        seconds = timestamp.getEpochSecond();
        picoseconds = timestamp.getNano() * 1000L;
      } else {
        throw new IllegalArgumentException(
            "Unsupported timestamp value type: " + value.getClass().getName());
      }

      Descriptor messageType = Preconditions.checkArgumentNotNull(fieldDescriptor).getMessageType();
      converted =
          DynamicMessage.newBuilder(messageType)
              .setField(messageType.findFieldByName("seconds"), seconds)
              .setField(messageType.findFieldByName("picoseconds"), picoseconds)
              .build();

    } else {
      @Nullable ThrowingBiFunction<String, Object, @Nullable Object> converter =
          TYPE_MAP_PROTO_CONVERTERS.get(schemaInformation.getType());
      if (converter == null) {
        throw new RuntimeException("Unknown type " + schemaInformation.getType());
      }
      converted = converter.apply(schemaInformation.getFullName(), value);
    }

View on GitHub (pinned to 12126d8942)

Solutions

  1. Convert the value to java.time.Instant before putting it in the TableRow (Instant.ofEpochMilli(millis) or value.toInstant()).
  2. If it's a String, ensure ISO-8601 format compatible with the string converter.
  3. For legacy Joda Instant, keep it — it is accepted — but don't mix with java.util.Date.
  4. Fix upstream serialization to emit epoch millis or ISO strings instead of Date objects.

Example fix

// before
row.set("ts", new java.util.Date());
// after
row.set("ts", Instant.ofEpochMilli(date.getTime()));
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = row.get("ts"); if (!(v instanceof Instant || v instanceof org.joda.time.Instant || v instanceof Long || v instanceof String)) { throw new IllegalArgumentException("ts must be Instant/Long/String"); }

Type guard

boolean isTimestampValue(Object v) { return v instanceof java.time.Instant || v instanceof org.joda.time.Instant || v instanceof Long || v instanceof String; }

Try / catch

try { writeRow(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported timestamp value type")) row.set("ts", coerceToInstant(row.get("ts"))); }

Prevention

When it happens

Trigger: Setting a TIMESTAMP field in a TableRow to an unsupported object type — e.g. java.util.Date, java.sql.Timestamp, LocalDateTime, ZonedDateTime — then writing via the Storage API proto conversion.

Common situations: JDBC/Spark sources producing java.sql.Timestamp; Jackson deserializing timestamps into Date or LocalDateTime; mixing java.time and Joda time types after a Beam migration (Beam moved from Joda to java.time).

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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