{"record":{"id":"88364743d00d7267","repo":"apache/beam","slug":"writing-of-map-type-is-not-supported-by-the-default","errorCode":null,"errorMessage":"Writing of MAP type is not supported by the default UserDataMapper","messagePattern":"Writing of MAP type is not supported by the default UserDataMapper","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreDefaultUserDataMapper.java","lineNumber":96,"sourceCode":"        return ((Boolean) value) ? \"1\" : \"0\";\n      case BYTES:\n        return new String((byte[]) value, StandardCharsets.UTF_8);\n      case ARRAY:\n        throw new UnsupportedOperationException(\n            \"Writing of ARRAY type is not supported by the default UserDataMapper\");\n      case ITERABLE:\n        throw new UnsupportedOperationException(\n            \"Writing of ITERABLE type is not supported by the default UserDataMapper\");\n      case MAP:\n        throw new UnsupportedOperationException(\n            \"Writing of MAP type is not supported by the default UserDataMapper\");\n      case ROW:\n        throw new UnsupportedOperationException(\n            \"Writing of nested ROW type is not supported by the default UserDataMapper\");\n      case LOGICAL_TYPE:\n        return convertLogicalTypeFieldToString(type, value);\n      default:\n        throw new UnsupportedOperationException(\n            String.format(\n                \"Writing of %s type is not supported by the default UserDataMapper\",\n                type.getTypeName().name()));\n    }\n  }\n\n  @Override\n  public List<String> mapRow(Row element) {\n    List<String> res = new ArrayList<>();\n\n    Schema s = element.getSchema();\n    for (int i = 0; i < s.getFieldCount(); i++) {\n      res.add(convertFieldToString(s.getField(i).getType(), element.getValue(i)));\n    }\n\n    return res;\n  }\n}","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreDefaultUserDataMapper.java#L78-L114","documentation":"This is the default branch of convertFieldToString in the default SingleStoreUserDataMapper. Note that the MAP case above it throws the same-family \"MAP not supported\" message; any field type not explicitly handled (e.g. MAP and other exotic type names) reaches the default branch, which formats the type name into an UnsupportedOperationException. Line 96 corresponds to the MAP branch throwing \"Writing of MAP type is not supported by the default UserDataMapper\".","triggerScenarios":"SingleStoreIO.write() with the default UserDataMapper where a Row field's Schema.FieldType has TypeName MAP (or any unhandled type reaching the default branch).","commonSituations":"Writing map/dictionary-valued fields (e.g. from JSON or protobuf map fields) directly to SingleStore.","solutions":["Convert map fields to JSON strings before writing","Normalize maps into key/value rows or scalar columns","Provide a custom UserDataMapper that serializes maps"],"exampleFix":"// before\n// field type MAP<STRING,STRING> -> throws\n// after\n// field type STRING; new ObjectMapper().writeValueAsString(map)","handlingStrategy":"validation","validationCode":"boolean hasMap = schema.getFields().stream().anyMatch(f -> f.getType().getTypeName() == Schema.TypeName.MAP); if (hasMap) throw new IllegalArgumentException(\"Serialize maps to JSON before SingleStore write\");","typeGuard":null,"tryCatchPattern":"try { rows.apply(SingleStoreIO.write()...); } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"not supported by the default UserDataMapper\")) { /* flatten/map to JSON */ } throw e; }","preventionTips":["Treat the default UserDataMapper as scalar-only: convert nested structures upstream","Add a schema lint step that rejects MAP/ARRAY/ITERABLE/ROW fields at graph construction time","Keep a JSON-encoding helper handy for map-shaped fields"],"tags":["java","beam","singlestore","write","map"],"backgroundTag":"operation-not-supported","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}