{"record":{"id":"9ece7cbb41caa71e","repo":"apache/beam","slug":"unable-to-infer-a-coder-for-type-s","errorCode":null,"errorMessage":"Unable to infer a coder for type %s","messagePattern":"Unable to infer a coder for type (.+?)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreUtil.java","lineNumber":69,"sourceCode":"    }\n\n    TypeDescriptor<OutputT> outputType =\n        TypeDescriptors.extractFromTypeParameters(\n            rowMapper,\n            SingleStoreIO.RowMapper.class,\n            new TypeDescriptors.TypeVariableExtractor<\n                SingleStoreIO.RowMapper<OutputT>, OutputT>() {});\n    try {\n      return schemaRegistry.getSchemaCoder(outputType);\n    } catch (NoSuchSchemaException e) {\n      log.warn(\n          \"Unable to infer a schema for type {}. Attempting to infer a coder without a schema.\",\n          outputType);\n    }\n    try {\n      return registry.getCoder(outputType);\n    } catch (CannotProvideCoderException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Unable to infer a coder for type %s\", outputType));\n    }\n  }\n\n  public static String getSelectQuery(@Nullable String table, @Nullable String query) {\n    if (table != null && query != null) {\n      throw new IllegalArgumentException(\"withTable() can not be used together with withQuery()\");\n    } else if (table != null) {\n      return \"SELECT * FROM \" + SingleStoreUtil.escapeIdentifier(table);\n    } else if (query != null) {\n      return query;\n    } else {\n      throw new IllegalArgumentException(\"One of withTable() or withQuery() is required\");\n    }\n  }\n\n  public static <OutputT> OutputT getArgumentWithDefault(\n      @Nullable OutputT value, OutputT defaultValue) {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreUtil.java#L51-L87","documentation":"SingleStoreIO uses Apache Beam's coder registry to derive a Coder for the output type when no schema can be inferred. If the registry cannot provide a coder (CannotProvideCoderException), inferCoder fails fast with this IllegalArgumentException. It means the element type of your read result is not one Beam can serialize automatically.","triggerScenarios":"Calling SingleStoreIO.read() (or apply of the read transform) with a generic output type such as a POJO without @DefaultSchema/@SchemaCreate annotation, a non-static inner class, a type without a registered Coder, or raw/generic type parameters erased to Object.","commonSituations":"Users map SingleStore rows into custom domain classes that Beam cannot infer coders for; using complex types (LocalDateTime, BigDecimal wrappers, interfaces) without schema annotation; running with generic type erasure so registry.getCoder(Object) fails.","solutions":["Annotate the output class with @DefaultSchema(JavaBeanSchema.class) (or AutoValueSchema) and ensure it is a public static class with proper getters, so a schema (and coder) is inferred.","Register a custom coder via CoderRegistry (pipeline.getCoderRegistry().registerCoderForClass(MyType.class, MyCoder.class)) before running the pipeline.","Use a type Beam already supports (e.g. KV, Row, TableRow, a class with an Avro-specific reflection coder).","If a schema is the problem, resolve it explicitly: SchemaCoder.of(schema, typeDescriptor, toRowFn, fromRowFn)."],"exampleFix":"// before\nPCollection<MyPojo> rows = pipeline.apply(SingleStoreIO.<MyPojo>read()...);\n\n// after\n@DefaultSchema(JavaBeanSchema.class)\npublic class MyPojo { /* public getters/setters, static class */ }\nPCollection<MyPojo> rows = pipeline.apply(SingleStoreIO.<MyPojo>read()...);","handlingStrategy":"validation","validationCode":"// Ensure the type is schema-annotated before building the read\nif (!MyPojo.class.isAnnotationPresent(DefaultSchema.class)) {\n  throw new IllegalStateException(\"Add @DefaultSchema(JavaBeanSchema.class) to \" + MyPojo.class);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Annotate output POJOs with @DefaultSchema and keep them static with JavaBean getters/setters.","Register custom coders in the pipeline's CoderRegistry up front.","Prefer well-known Beam types (Row, TableRow, KV) for SingleStore reads."],"tags":["beam","coder","serialization","pipeline-config"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}