{"record":{"id":"427eece57c8b40d0","repo":"apache/beam","slug":"unsupported-spanner-type-s-for-column-s","errorCode":null,"errorMessage":"Unsupported spanner type %s for column %s.","messagePattern":"Unsupported spanner type (.+?) for column (.+?)\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/StructUtils.java","lineNumber":411,"sourceCode":"        return struct.getFloat(column);\n      case FLOAT64:\n        return struct.getDouble(column);\n      case NUMERIC:\n        return struct.getBigDecimal(column);\n      case STRING:\n        return struct.getString(column);\n      case ARRAY:\n        return getStructArrayValue(\n            struct, struct.getColumnType(column).getArrayElementType(), field);\n      case STRUCT:\n        @Nullable Schema schema = field.getType().getRowSchema();\n        if (schema == null) {\n          throw new NullPointerException(\"Null schema at field \" + field.getName());\n        } else {\n          return structToBeamRow(struct.getStruct(column), schema);\n        }\n      default:\n        throw new RuntimeException(\n            String.format(\"Unsupported spanner type %s for column %s.\", typeCode, column));\n    }\n  }\n\n  private static @Nullable Object getStructArrayValue(\n      Struct struct, Type arrayType, Schema.Field field) {\n    Type.Code arrayCode = arrayType.getCode();\n    String column = field.getName();\n    if (struct.isNull(column)) {\n      return null;\n    }\n    switch (arrayCode) {\n      case BOOL:\n        return struct.getBooleanList(column);\n      case BYTES:\n        return struct.getBytesList(column);\n      case TIMESTAMP:\n        // Check if expects MicrosInstant in arrays","sourceCodeStart":393,"sourceCodeEnd":429,"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#L393-L429","documentation":"getStructValue reads a single column of a Spanner Struct into a Beam Row value. When the column's Spanner TypeCode has no case in the switch (an unrecognized or unmapped type), this RuntimeException names both the type code and the column. Unlike the IllegalArgumentException guards, this is a RuntimeException, typically signaling a schema/type the SDK version does not know.","triggerScenarios":"Reading Spanner rows (structValues -> getStructValue) where a column's TypeCode is not one of the mapped codes (e.g. newer Spanner types like JSON/PROTO or unmapped codes) at read time.","commonSituations":"Spanner databases using newer column types with an older Beam SDK; queries returning exotic expressions whose inferred type is unmapped.","solutions":["Upgrade the Beam Google Cloud Platform SDK so the Spanner TypeCode is mapped.","Change the query to cast the column to a supported type (e.g. CAST(col AS STRING)).","Wrap the read in try-catch for RuntimeException and produce a diagnostic schema dump to identify the offending column."],"exampleFix":"// before\nSELECT id, user_profile FROM users -- user_profile is JSON type\n// after\nSELECT id, TO_JSON_STRING(user_profile) AS user_profile FROM users","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Row row = StructUtils.structToBeamRow(struct, schema);\n} catch (RuntimeException e) {\n  LOG.error(\"Failed to convert Spanner row: {}\", e.getMessage());\n  throw new IOException(\"Unsupported Spanner column type encountered; upgrade SDK or cast in query\", e);\n}","preventionTips":["Cast unsupported column types (JSON/PROTO) to STRING in read queries.","Upgrade the Beam SDK when adopting new Spanner column types.","Test reads against production-like schemas in CI."],"tags":["spanner","schema","unsupported-type","java"],"backgroundTag":"unsupported-enum-value","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"}