{"record":{"id":"e95a32e537d53e56","repo":"apache/beam","slug":"unsupported-beam-type-s-while-translating-row-to-struct","errorCode":null,"errorMessage":"Unsupported beam type '%s' while translating row to struct.","messagePattern":"Unsupported beam type '(.+?)' while translating row to struct\\.","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":212,"sourceCode":"              if (byteValue == null) {\n                structBuilder.set(column).to((Long) null);\n              } else {\n                structBuilder.set(column).to(byteValue);\n              }\n              break;\n            case BYTES:\n              byte @Nullable [] bytes = row.getBytes(column);\n              if (bytes == null) {\n                structBuilder.set(column).to((ByteArray) null);\n              } else {\n                structBuilder.set(column).to(ByteArray.copyFrom(bytes));\n              }\n              break;\n            case BOOLEAN:\n              structBuilder.set(column).to(row.getBoolean(column));\n              break;\n            default:\n              throw new IllegalArgumentException(\n                  String.format(\n                      \"Unsupported beam type '%s' while translating row to struct.\",\n                      field.getType().getTypeName()));\n          }\n        });\n    return structBuilder.build();\n  }\n\n  public static Type beamTypeToSpannerType(Schema.FieldType beamType) {\n    switch (beamType.getTypeName()) {\n      case ARRAY:\n      case ITERABLE:\n        Schema.@Nullable FieldType elementType = beamType.getCollectionElementType();\n        if (elementType == null) {\n          throw new NullPointerException(\"Null element type\");\n        } else {\n          return Type.array(simpleBeamTypeToSpannerType(elementType));\n        }","sourceCodeStart":194,"sourceCodeEnd":230,"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#L194-L230","documentation":"beamRowToStruct converts a Beam Row back into a Spanner Struct for writes/mutations. When a field's Beam type name has no case in the translation switch, this IllegalArgumentException names the unsupported Beam type. It guards the write path against types the Spanner sink cannot encode.","triggerScenarios":"Passing a Beam Row whose schema contains a field type outside the supported set (e.g. logical or bytes-adjacent types not handled) into StructUtils.beamRowToStruct, including via addIterableToStructBuilder on array fields.","commonSituations":"PCollection schemas built programmatically with unusual field types; rows produced by upstream transforms adding custom logical types; schema drift after pipeline changes.","solutions":["Change the offending Row field to a supported Beam type (STRING, INT64, FLOAT64, BOOLEAN, DATETIME, etc.) before conversion.","Serialize the unsupported value to a supported representation (e.g. store as STRING/JSON) and parse it later.","Extend the conversion switch (fork/patch StructUtils) if the type is legitimately needed."],"exampleFix":"// before\nSchema.Field.of(\"created\", Schema.FieldType.logicalType(...))\n// after\nSchema.Field.of(\"created\", Schema.FieldType.DATETIME)","handlingStrategy":"validation","validationCode":"// check Row schema before beamRowToStruct\nfor (Schema.Field f : row.getSchema().getFields()) {\n  Schema.TypeName t = f.getType().getTypeName();\n  if (!(t == Schema.TypeName.STRING || t == Schema.TypeName.INT64 || t == Schema.TypeName.FLOAT64\n        || t == Schema.TypeName.BOOLEAN || t == Schema.TypeName.DATETIME || t == Schema.TypeName.ITERABLE)) {\n    throw new IllegalArgumentException(\"Field \" + f.getName() + \" has unsupported type \" + t);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict PCollection schemas for Spanner writes to supported Beam types.","Avoid custom logical types in Spanner-sink schemas.","Add a schema assertion step (e.g. beam testUtils assertSchema) before writes."],"tags":["spanner","beam-row","type-conversion","java"],"backgroundTag":"type-mismatch","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"}