{"record":{"id":"4d22cd401f69f43d","repo":"apache/beam","slug":"unable-to-translate-beam-type-s-to-spanner-type","errorCode":null,"errorMessage":"Unable to translate beam type %s to Spanner type","messagePattern":"Unable to translate beam type (.+?) to Spanner type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/StructUtils.java","lineNumber":266,"sourceCode":"      case INT64:\n      case INT32:\n      case INT16:\n        return Type.int64();\n      case DOUBLE:\n        return Type.float64();\n      case FLOAT:\n        return Type.float32();\n      case DECIMAL:\n        return Type.numeric();\n      case STRING:\n        return Type.string();\n      case BOOLEAN:\n        return Type.bool();\n        // TODO: implement logical type date and timestamp\n      case DATETIME:\n        return Type.timestamp();\n      default:\n        throw new IllegalArgumentException(\n            String.format(\n                \"Unable to translate beam type %s to Spanner type\", beamType.getTypeName()));\n    }\n  }\n\n  private static Iterable<Type.StructField> translateRowFieldsToStructFields(\n      List<Schema.Field> rowFields) {\n    return rowFields.stream()\n        .map(field -> Type.StructField.of(field.getName(), beamTypeToSpannerType(field.getType())))\n        .collect(toList());\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  private static void addIterableToStructBuilder(\n      Struct.Builder structBuilder, @Nullable Iterable<Object> iterable, Schema.Field field) {\n    String column = field.getName();\n    Schema.FieldType beamIterableType = field.getType().getCollectionElementType();\n    if (beamIterableType == null) {","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/StructUtils.java#L248-L284","documentation":"simpleBeamTypeToSpannerType maps scalar Beam field types to Cloud Spanner Type objects for schema creation. Unmapped types (everything past the supported set) raise this IllegalArgumentException. Note DATETIME is mapped to Type.timestamp(); truly unsupported types like DECIMAL or MAP hit the default branch.","triggerScenarios":"Calling beamTypeToSpannerType (e.g. when writing rows or creating Spanner tables from a Beam schema) with a Beam FieldType such as DECIMAL, BYTES, MAP, or a custom logical type not covered by simpleBeamTypeToSpannerType.","commonSituations":"Writing PCollections with NUMERIC/decimal columns to Spanner; schemas containing bytes or map fields; Beam logical types like Json or custom types.","solutions":["Convert the unsupported field to a supported Beam type before writing (e.g. DECIMAL to STRING, or DATETIME for timestamps).","Pre-convert complex types (maps, bytes) to STRING/JSON-compatible representations.","Check the supported-type list in StructUtils and adjust your Schema to match it."],"exampleFix":"// before\nSchema.Field.of(\"amount\", Schema.FieldType.DECIMAL)\n// after\nSchema.Field.of(\"amount\", Schema.FieldType.STRING) // or convert to DATETIME-compatible representation","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean isSpannerWritable(Schema.FieldType t) {\n  switch (t.getTypeName()) {\n    case STRING: case INT64: case FLOAT64: case BOOLEAN: case DATETIME:\n      return true;\n    default:\n      return false;\n  }\n}","tryCatchPattern":null,"preventionTips":["Map DECIMAL fields to STRING or FLOAT64 before Spanner writes.","Encode maps/bytes as STRING (base64/JSON) upstream.","Keep the write-path Schema in sync with simpleBeamTypeToSpannerType's supported set."],"tags":["spanner","beam-schema","type-conversion","java"],"backgroundTag":"unsupported-dtype","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}