{"record":{"id":"8b718041c59f0cef","repo":"apache/beam","slug":"cannot-provide-a-coder-for-a-beam-row-please-provide-a","errorCode":null,"errorMessage":"Cannot provide a coder for a Beam Row. Please provide a schema instead using PCollection.setRowSchema.","messagePattern":"Cannot provide a coder for a Beam Row\\. Please provide a schema instead using PCollection\\.setRowSchema\\.","errorType":"exception","errorClass":"CannotProvideCoderException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java","lineNumber":611,"sourceCode":"    return c == null || c.isEmpty();\n  }\n\n  /** The list of {@link CoderProvider coder providers} to use to provide Coders. */\n  private ArrayDeque<CoderProvider> coderProviders;\n\n  /**\n   * Returns a {@link Coder} to use for values of the given type, in a context where the given types\n   * use the given coders.\n   *\n   * @throws CannotProvideCoderException if a coder cannot be provided\n   */\n  private <T> Coder<T> getCoderFromTypeDescriptor(\n      TypeDescriptor<T> typeDescriptor, SetMultimap<Type, Coder<?>> typeCoderBindings)\n      throws CannotProvideCoderException {\n    Type type = typeDescriptor.getType();\n    Coder<?> coder;\n    if (typeDescriptor.equals(TypeDescriptors.rows())) {\n      throw new CannotProvideCoderException(\n          \"Cannot provide a coder for a Beam Row. Please provide a schema instead using PCollection.setRowSchema.\");\n    }\n    if (typeCoderBindings.containsKey(type)) {\n      Set<Coder<?>> coders = typeCoderBindings.get(type);\n      if (coders.size() == 1) {\n        coder = Iterables.getOnlyElement(coders);\n      } else {\n        throw new CannotProvideCoderException(\n            String.format(\n                \"Cannot provide a coder for type variable %s\"\n                    + \" because the actual type is over specified by multiple\"\n                    + \" incompatible coders %s.\",\n                type, coders),\n            ReasonCode.OVER_SPECIFIED);\n      }\n    } else if (type instanceof Class<?>) {\n      coder = getCoderFromFactories(typeDescriptor, Collections.emptyList());\n    } else if (type instanceof ParameterizedType) {","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java#L593-L629","documentation":"Beam Rows cannot be encoded with a traditional Coder; they are serialized via a Schema instead. When getCoderFromTypeDescriptor is asked for a coder whose type is TypeDescriptors.rows(), it fails fast with CannotProvideCoderException pointing the user to set a schema on the PCollection. This prevents users from trying to route Row data through the coder registry.","triggerScenarios":"Calling CoderRegistry.getCoder(TypeDescriptor.of(Row.class)) or TypeDescriptors.rows(); letting the registry infer a coder for a PCollection<Row> without an associated schema.","commonSituations":"Converting schema-agnostic pipeline code to schema-udf/Row-based processing; generic helper methods that call getCoder on arbitrary TypeDescriptors that may be Row.","solutions":["Attach a schema instead: pcollection.setRowSchema(mySchema) — the schema determines serialization.","Ensure upstream transforms producing Rows use Schema-aware PTransforms so no coder is needed.","Refactor helper code to special-case TypeDescriptors.rows() before requesting a coder."],"exampleFix":"// before\nCoder<Row> coder = registry.getCoder(TypeDescriptor.of(Row.class));\n// after\npcollection.setRowSchema(Schema.builder().addStringField(\"name\").build());","handlingStrategy":"type-guard","validationCode":"if (TypeDescriptors.rows().equals(typeDescriptor)) {\n  throw new IllegalArgumentException(\"Use setRowSchema for Rows, not a coder\");\n}","typeGuard":"boolean isRow = TypeDescriptors.rows().equals(typeDescriptor);","tryCatchPattern":"try {\n  coder = registry.getCoder(td);\n} catch (CannotProvideCoderException e) {\n  // if message mentions Row, attach a schema via setRowSchema instead\n}","preventionTips":["Never request coders for Row types; rely on schemas.","Special-case TypeDescriptors.rows() in generic helper utilities.","Use Schema-aware transforms for Row data."],"tags":["java","apache-beam","schema","row"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}