{"record":{"id":"5f51bfe50dd40216","repo":"apache/beam","slug":"unsupported-logical-type-logicaltype-getidentifier","errorCode":null,"errorMessage":"Unsupported logical type \" + logicalType.getIdentifier()","messagePattern":"Unsupported logical type \" \\+ logicalType\\.getIdentifier\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProto.java","lineNumber":401,"sourceCode":"  @VisibleForTesting\n  static Object scalarToProtoValue(\n      @Nullable FieldDescriptor fieldDescriptor, FieldType beamFieldType, Object value) {\n    if (beamFieldType.getTypeName() == TypeName.LOGICAL_TYPE) {\n      @Nullable LogicalType<?, ?> logicalType = beamFieldType.getLogicalType();\n      if (logicalType == null) {\n        throw new RuntimeException(\"Unexpectedly null logical type \" + beamFieldType);\n      }\n      if (logicalType.getIdentifier().equals(Timestamp.IDENTIFIER)) {\n        Instant instant = (Instant) value;\n        Descriptor timestampPicosDescriptor =\n            Preconditions.checkNotNull(fieldDescriptor).getMessageType();\n        return buildTimestampPicosMessage(timestampPicosDescriptor, instant);\n      }\n      @Nullable\n      BiFunction<LogicalType<?, ?>, Object, Object> logicalTypeEncoder =\n          LOGICAL_TYPE_ENCODERS.get(logicalType.getIdentifier());\n      if (logicalTypeEncoder == null) {\n        throw new RuntimeException(\"Unsupported logical type \" + logicalType.getIdentifier());\n      }\n      return logicalTypeEncoder.apply(logicalType, value);\n    } else {\n      @Nullable\n      Function<Object, Object> encoder = PRIMITIVE_ENCODERS.get(beamFieldType.getTypeName());\n      if (encoder == null) {\n        throw new RuntimeException(\"Unexpected beam type \" + beamFieldType);\n      }\n      return encoder.apply(value);\n    }\n  }\n\n  static Object mapEntryToProtoValue(\n      Descriptor descriptor,\n      FieldType keyFieldType,\n      FieldType valueFieldType,\n      Map.Entry<Object, Object> entryValue) {\n    DynamicMessage.Builder builder = DynamicMessage.newBuilder(descriptor);","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProto.java#L383-L419","documentation":"BeamRowToStorageApiProto.scalarToProtoValue converts a Beam Row field value into a protobuf value for the BigQuery Storage Write API. For fields whose Beam type is a logical type, it looks up an encoder in the LOGICAL_TYPE_ENCODERS map by the LogicalType's identifier; if no encoder is registered for that identifier, it throws this RuntimeException.","triggerScenarios":"Calling toProtoValue on a Row whose Schema contains a field with a custom/unregistered LogicalType (e.g. a user-defined LogicalType or a standard logical type Beam does not map to BigQuery) while converting rows for the BigQuery Storage API sink.","commonSituations":"Users add a custom LogicalType to their schema (e.g. via Schema.builder().addLogicalTypeField) and then write to BigQuery with STORAGE_API/STORAGE_WRITE_API method; Beam has no built-in mapping for that identifier so serialization fails at runtime, typically in a DoFn during pipeline execution.","solutions":["Remove or replace the custom LogicalType field with a primitive Beam type (STRING, LONG, etc.) the encoder supports","Register an encoder in LOGICAL_TYPE_ENCODERS via its registration mechanism, mapping the identifier to a supported proto type","Convert the logical-typed value to a supported type in a PTransform before the BigQuery sink","Fall back to a non-Storage Write sink method (e.g. FILE_LOADS) that serializes rows differently"],"exampleFix":"// before\nSchema.Field f = Schema.Field.of(\"id\", Schema.FieldType.logicalType(new MyUuidType()));\n// after\nSchema.Field f = Schema.Field.of(\"id\", Schema.FieldType.STRING); // convert UUID -> String in a MapElements","handlingStrategy":"validation","validationCode":"Schema.FieldType ft = field.getType();\nif (ft.getTypeName().equals(Schema.TypeName.LOGICAL_TYPE)) {\n  String id = ft.getLogicalType().getIdentifier();\n  if (!Set.of(\"Char\", \"UUID\", \"ISO-INSTANT\").contains(id)) throw new IllegalArgumentException(\"No BigQuery encoder for logical type \" + id);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer primitive Beam types for BigQuery sinks","Register encoders for any custom LogicalType before writing","Test schema conversion in a unit test before running the pipeline"],"tags":["java","apache-beam","bigquery","serialization","logical-type"],"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"}