{"record":{"id":"d2295ad336dc9c4d","repo":"apache/beam","slug":"does-not-support-converting-decimal-type-value","errorCode":null,"errorMessage":"Does not support converting DECIMAL type value","messagePattern":"Does not support converting DECIMAL type value","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":1155,"sourceCode":"\n  private static @Nullable Object convertAvroPrimitiveTypes(TypeName beamType, Object value) {\n    switch (beamType) {\n      case BYTE:\n        return ((Long) value).byteValue();\n      case INT16:\n        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(","sourceCodeStart":1137,"sourceCodeEnd":1173,"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#L1137-L1173","documentation":"Thrown as RuntimeException from convertAvroPrimitiveTypes when the Beam field type is DECIMAL but the code path went through the primitive converter instead of convertAvroNumeric. DECIMAL requires Avro 'bytes' with a decimal logical type handled specially; reaching the primitive switch with DECIMAL means the value arrived in a form this converter does not support.","triggerScenarios":"An Avro value being converted for a Beam DECIMAL field hits convertAvroPrimitiveTypes — e.g. via PassThroughLogicalType delegating a base type of DECIMAL, or nested/array elements routed through the primitive path, where the decimal bytes conversion (convertAvroNumeric) is unavailable.","commonSituations":"BigQuery NUMERIC/BIGNUMERIC columns inside custom logical types or passthrough wrappers; older Beam versions where nested decimal handling was incomplete; numeric fields nested in ARRAY/RECORD converted via the primitive branch.","solutions":["Upgrade Beam: newer versions route DECIMAL through convertAvroNumeric and support nested NUMERIC conversion.","Ensure the Avro schema carries the decimal logical type so the DECIMAL branch (convertAvroNumeric) is taken, not the primitive one.","Change the Beam field type to STRING or BYTES and decode the decimal yourself.","If using a custom PassThroughLogicalType, set its base type to BYTES and convert to BigDecimal manually after conversion."],"exampleFix":"// before\nFieldType f = FieldType.STRING; // then manual parse of NUMERIC\n// after\nFieldType f = FieldType.DECIMAL; // converted via convertAvroNumeric","handlingStrategy":"validation","validationCode":"// Java: ensure DECIMAL fields don't route through the primitive converter; keep them as top-level FieldType.DECIMAL with a proper avro decimal logical type\nschema.getFields().forEach(f -> {\n  if (f.getType().getTypeName() == TypeName.DECIMAL) {\n    // requires avro bytes + decimal logical type; verify upstream schema\n  }\n});","typeGuard":null,"tryCatchPattern":"try { value = convertAvroFormat(field, v, opts); } catch (RuntimeException e) { if (e.getMessage().equals(\"Does not support converting DECIMAL type value\")) { // decode BigDecimal from avro bytes manually } throw e; }","preventionTips":["Keep Beam up to date; newer versions handle nested NUMERIC correctly.","Ensure Avro schemas carry the decimal logical type for NUMERIC/BIGNUMERIC columns.","Avoid wrapping DECIMAL fields in custom passthrough logical types."],"tags":["java","beam","bigquery","avro","decimal"],"backgroundTag":"unsupported-operation","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"}