apache/beam · error · RuntimeException

Unknown type %s

Error message

Unknown type %s

What it means

protoTypeToJsonType maps a protobuf TableFieldSchema.Type (e.g. STRING, INT64, TIMESTAMP) to the legacy JSON API type string via TYPE_MAP_PROTO_JSON. An unmapped proto type means the map lookup returns null and the method throws RuntimeException("Unknown type ...").

Source

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

      // repeated.
      return resultMode.equals(TableFieldSchema.Mode.REPEATED)
          ? resultMode
          : TableFieldSchema.Mode.NULLABLE;
    }
  }

  public static String protoModeToJsonMode(TableFieldSchema.Mode protoMode) {
    String jsonMode = MODE_MAP_PROTO_JSON.get(protoMode);
    if (jsonMode == null) {
      throw new RuntimeException("Unknown mode " + protoMode);
    }
    return jsonMode;
  }

  public static String protoTypeToJsonType(TableFieldSchema.Type protoType) {
    String type = TYPE_MAP_PROTO_JSON.get(protoType);
    if (type == null) {
      throw new RuntimeException("Unknown type " + protoType);
    }
    return type;
  }

  public static TableFieldSchema.Type typeToProtoType(String type) {
    TableFieldSchema.Type protoType = TYPE_MAP_JSON_PROTO.get(type);
    if (protoType == null) {
      throw new RuntimeException("Unknown type " + type);
    }
    return protoType;
  }

  public static com.google.api.services.bigquery.model.TableSchema protoSchemaToTableSchema(
      TableSchema protoTableSchema) {
    com.google.api.services.bigquery.model.TableSchema tableSchema =
        new com.google.api.services.bigquery.model.TableSchema();
    List<com.google.api.services.bigquery.model.TableFieldSchema> tableFields =
        Lists.newArrayListWithExpectedSize(protoTableSchema.getFieldsCount());

View on GitHub (pinned to 12126d8942)

Solutions

  1. Upgrade Beam / google-cloud-bigquery so the type map includes the new type.
  2. Pre-convert the field to a supported type in the source query/schema.
  3. Wrap the conversion and skip/flatten unsupported fields if they are not needed downstream.

Example fix

// before
String jsonType = TableRowToStorageApiProto.protoTypeToJsonType(unmappedProtoType); // throws
// after
if (TYPE_MAP_PROTO_JSON.get(unmappedProtoType) == null) {
  LOG.warn("Skipping unsupported type {}", unmappedProtoType);
  return null;
}
Defensive patterns

Strategy: try-catch

Validate before calling

for (TableFieldSchema f : schema.getFields()) {
  if (TableRowToStorageApiProto.typeToProtoType(f.getType()) == null) { /* pre-validate */ }
}

Try / catch

try {
  String jsonType = TableRowToStorageApiProto.protoTypeToJsonType(protoType);
} catch (RuntimeException e) {
  LOG.error("Proto type {} not mappable; upgrade Beam or change schema", protoType, e);
  throw e;
}

Prevention

When it happens

Trigger: Calling protoTypeToJsonType with a TableFieldSchema.Type missing from TYPE_MAP_PROTO_JSON — typically a type added in a newer BigQuery Storage API than the Beam version supports.

Common situations: Schema created by a newer BigQuery client/feature (e.g. new numeric or range types) processed by an older Beam version; converting proto schemas back to JSON TableSchema for display or legacy sinks.

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/4eca002dbcd22de4. Report an issue: GitHub.