{"record":{"id":"711d327cbe1023c7","repo":"apache/beam","slug":"tablerow-can-hold-arbitrary-instances-which-may-be-non","errorCode":null,"errorMessage":"TableRow can hold arbitrary instances, which may be non-deterministic.","messagePattern":"TableRow can hold arbitrary instances, which may be non-deterministic\\.","errorType":"exception","errorClass":"NonDeterministicException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryInsertErrorCoder.java","lineNumber":91,"sourceCode":"  // properly deserialized as such and not as an Integer instead.\n  private static final ObjectMapper MAPPER =\n      new ObjectMapper()\n          .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)\n          .enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);\n\n  private static final BigQueryInsertErrorCoder INSTANCE = new BigQueryInsertErrorCoder();\n  private static final TypeDescriptor<BigQueryInsertError> TYPE_DESCRIPTOR =\n      new TypeDescriptor<BigQueryInsertError>() {};\n\n  /**\n   * {@inheritDoc}\n   *\n   * @throws NonDeterministicException always. A {@link TableRow} can hold arbitrary {@link Object}\n   *     instances, which makes the encoding non-deterministic.\n   */\n  @Override\n  public void verifyDeterministic() throws NonDeterministicException {\n    throw new NonDeterministicException(\n        this, \"TableRow can hold arbitrary instances, which may be non-deterministic.\");\n  }\n\n  @Override\n  public TypeDescriptor<BigQueryInsertError> getEncodedTypeDescriptor() {\n    return TYPE_DESCRIPTOR;\n  }\n}\n","sourceCodeStart":73,"sourceCodeEnd":100,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryInsertErrorCoder.java#L73-L100","documentation":"BigQueryInsertErrorCoder.verifyDeterministic() always throws NonDeterministicException. A TableRow can hold arbitrary Object instances (e.g. Maps, custom objects) whose encoding may differ run to run, so the coder cannot guarantee deterministic encoding — a requirement for operations like grouping or stateful processing.","triggerScenarios":"Using BigQueryInsertError (e.g. from BigQueryIO write results with failed inserts) in an operation that requires deterministic coding, such as GroupByKey, Combine, or CoGroupByKey; the coder's verifyDeterministic is invoked during pipeline validation.","commonSituations":"Pipelines that join or aggregate failed-insert records to build retry batches or dead-letter metrics; developers keying on BigQueryInsertError or wrapping it in keyed PCollections.","solutions":["Extract deterministic fields (e.g. row content as JSON string, error message, table destination) into a stable POJO/String and group on that instead.","Apply a MapElements/ParDo to convert BigQueryInsertError to a deterministically-coded type before GroupByKey.","If only counting/metrics are needed, transform to simple key-value pairs (String/Long) before grouping."],"exampleFix":"// before\nfailedInserts.apply(GroupByKey.create()); // BigQueryInsertError is non-deterministic\n// after\nfailedInserts\n    .apply(MapElements.via(new SimpleFunction<BigQueryInsertError, KV<String, String>>() {\n      public KV<String, String> apply(BigQueryInsertError e) {\n        return KV.of(e.getTableRow().get(\"k\").toString(), e.getErrorMessages().toString());\n      }\n    }))\n    .apply(GroupByKey.create());","handlingStrategy":"type-guard","validationCode":"if (willBeGrouped(pcOfInsertErrors)) {\n  throw new IllegalStateException(\"BigQueryInsertError is non-deterministically coded; map to a deterministic type before grouping\");\n}","typeGuard":"static boolean isDeterministicallyCodable(Class<?> c) {\n  return !BigQueryInsertError.class.isAssignableFrom(c);\n}","tryCatchPattern":"try {\n  pipeline.apply(GroupByKey.create());\n} catch (NonDeterministicException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"TableRow can hold arbitrary instances\")) {\n    throw new IllegalStateException(\"Project BigQueryInsertError onto a deterministic key/value type first\", e);\n  } else { throw e; }\n}","preventionTips":["Never use BigQueryInsertError (or TableRow-based values) directly as group/combine/state inputs.","Project error records onto small deterministic POJOs or strings before grouping.","Review coder determinism requirements whenever adding GroupByKey to error-handling branches."],"tags":["java","bigquery","apache-beam","coder","non-deterministic"],"backgroundTag":"unsupported-operation","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"}