{"record":{"id":"c1f2e35b52bb4452","repo":"apache/beam","slug":"is-not-primitive-type","errorCode":null,"errorMessage":" is not primitive type.","messagePattern":" is not primitive type\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java","lineNumber":1161,"sourceCode":"        return ((Long) value).shortValue();\n      case INT32:\n        return ((Long) value).intValue();\n      case INT64:\n        return value; // Long\n      case FLOAT:\n        return ((Double) value).floatValue();\n      case DOUBLE:\n        return value; // Double\n      case BOOLEAN:\n        return value; // Boolean\n      case DECIMAL:\n        throw new RuntimeException(\"Does not support converting DECIMAL type value\");\n      case STRING:\n        return convertAvroString(value);\n      case BYTES:\n        return convertAvroBytes(value);\n      default:\n        throw new RuntimeException(beamType + \" is not primitive type.\");\n    }\n  }\n\n  private static @Nullable Object convertAvroString(@Nullable Object value) {\n    if (value == null) {\n      return null;\n    } else if (value instanceof Utf8) {\n      return ((Utf8) value).toString();\n    } else if (value instanceof String) {\n      return value;\n    } else {\n      throw new RuntimeException(\n          \"Does not support converting avro format: \" + value.getClass().getName());\n    }\n  }\n\n  private static @Nullable Object convertAvroBytes(@Nullable Object value) {\n    if (value == null) {","sourceCodeStart":1143,"sourceCodeEnd":1179,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java#L1143-L1179","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the custom LogicalType's getBaseType() to return the actual primitive it passes through (e.g. STRING, INT64).","Route composite types through convertAvroFormat's proper switch cases (ARRAY/ROW/MAP/DATETIME) rather than the primitive helper.","Upgrade Beam if a newly introduced TypeName is unhandled.","Check the beamType in the message and adjust the schema so the field uses a supported primitive."],"exampleFix":"// before\ngetBaseType() { return FieldType.DATETIME; } // not primitive-handled\n// after\ngetBaseType() { return FieldType.INT64; } // converted as primitive","handlingStrategy":"validation","validationCode":"// Java: check the base type of passthrough logical types is primitive\nif (t.getTypeName() == TypeName.LOGICAL_TYPE\n    && t.getLogical() instanceof PassThroughLogicalType) {\n  TypeName base = ((PassThroughLogicalType<?>) t.getLogical()).getBaseType().getTypeName();\n  if (!base.isPrimitiveType()) throw new IllegalStateException(\"Bad base type: \" + base);\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Set PassThroughLogicalType.getBaseType() to a genuinely primitive FieldType.","Route composite types (ARRAY/ROW/MAP/DATETIME) through convertAvroFormat's main switch, not the primitive helper."],"tags":["java","beam","bigquery","avro","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}