apache/beam · error · RuntimeException

is not primitive type.

Error message

 is not primitive type.

What it means

Thrown as RuntimeException from the default branch of convertAvroPrimitiveTypes when the Beam field type name is not one of the primitive types it handles (BYTE/INT16/INT32/INT64/FLOAT/DOUBLE/BOOLEAN/DECIMAL/STRING/BYTES). The message concatenates the offending beamType. It means a non-primitive (or unsupported) type was routed into the primitive conversion helper.

Source

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

        return ((Long) value).shortValue();
      case INT32:
        return ((Long) value).intValue();
      case INT64:
        return value; // Long
      case FLOAT:
        return ((Double) value).floatValue();
      case DOUBLE:
        return value; // Double
      case BOOLEAN:
        return value; // Boolean
      case DECIMAL:
        throw new RuntimeException("Does not support converting DECIMAL type value");
      case STRING:
        return convertAvroString(value);
      case BYTES:
        return convertAvroBytes(value);
      default:
        throw new RuntimeException(beamType + " is not primitive type.");
    }
  }

  private static @Nullable Object convertAvroString(@Nullable Object value) {
    if (value == null) {
      return null;
    } else if (value instanceof Utf8) {
      return ((Utf8) value).toString();
    } else if (value instanceof String) {
      return value;
    } else {
      throw new RuntimeException(
          "Does not support converting avro format: " + value.getClass().getName());
    }
  }

  private static @Nullable Object convertAvroBytes(@Nullable Object value) {
    if (value == null) {

View on GitHub (pinned to 12126d8942)

Solutions

  1. Fix the custom LogicalType's getBaseType() to return the actual primitive it passes through (e.g. STRING, INT64).
  2. Route composite types through convertAvroFormat's proper switch cases (ARRAY/ROW/MAP/DATETIME) rather than the primitive helper.
  3. Upgrade Beam if a newly introduced TypeName is unhandled.
  4. Check the beamType in the message and adjust the schema so the field uses a supported primitive.

Example fix

// before
getBaseType() { return FieldType.DATETIME; } // not primitive-handled
// after
getBaseType() { return FieldType.INT64; } // converted as primitive
Defensive patterns

Strategy: validation

Validate before calling

// Java: check the base type of passthrough logical types is primitive
if (t.getTypeName() == TypeName.LOGICAL_TYPE
    && t.getLogical() instanceof PassThroughLogicalType) {
  TypeName base = ((PassThroughLogicalType<?>) t.getLogical()).getBaseType().getTypeName();
  if (!base.isPrimitiveType()) throw new IllegalStateException("Bad base type: " + base);
}

Try / catch

try { ... } catch (RuntimeException e) { if (e.getMessage().endsWith("is not primitive type.")) { log.error("Non-primitive type routed to primitive converter: {}", e.getMessage()); } throw e; }

Prevention

When it happens

Trigger: convertAvroPrimitiveTypes called with a TypeName like DATETIME, ARRAY, ROW, MAP, or LOGICAL_TYPE — typically from a PassThroughLogicalType whose base type was misconfigured, or internal routing bugs in custom/forked code.

Common situations: Custom logical types with wrong getBaseType(); forked converters dispatching all types to the primitive helper; Beam version skew where a new TypeName isn't handled.

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