{"record":{"id":"8324353651567cf0","repo":"apache/beam","slug":"unsupported-logical-type-logicaltype-getname","errorCode":null,"errorMessage":"Unsupported logical type \" + logicalType.getName()","messagePattern":"Unsupported logical type \" \\+ logicalType\\.getName\\(\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProto.java","lineNumber":569,"sourceCode":"\n      // Handle negative timestamps (before epoch)\n      if (nanos < 0 && nanoAdjustment != 0) {\n        seconds -= 1;\n        nanoAdjustment += NANOS_PER_SECOND;\n      }\n\n      long picoseconds = nanoAdjustment * PICOS_PER_NANO;\n      return buildTimestampPicosMessage(\n          Preconditions.checkNotNull(descriptor).getMessageType(), seconds, picoseconds);\n    }\n    LogicalType logicalType = LogicalTypes.fromSchema(type.getType());\n\n    if (logicalType != null) {\n      @Nullable\n      BiFunction<LogicalType, Object, Object> logicalTypeEncoder =\n          LOGICAL_TYPE_ENCODERS.get(logicalType.getName());\n      if (logicalTypeEncoder == null) {\n        throw new IllegalArgumentException(\"Unsupported logical type \" + logicalType.getName());\n      }\n      return logicalTypeEncoder.apply(logicalType, value);\n    } else {\n      @Nullable Function<Object, Object> encoder = PRIMITIVE_ENCODERS.get(type.getType().getType());\n      if (encoder == null) {\n        throw new RuntimeException(\"Unexpected beam type \" + fieldSchema);\n      }\n      return encoder.apply(value);\n    }\n  }\n}\n","sourceCodeStart":551,"sourceCodeEnd":581,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProto.java#L551-L581","documentation":"scalarToProtoValue looks up an encoder for a field's Avro logical type in LOGICAL_TYPE_ENCODERS. If a logical type is present but has no registered encoder (e.g. unknown or custom named logical types like \"decimal-metadata\" or user-defined logical types), it throws IllegalArgumentException(\"Unsupported logical type ...\"). Only a fixed set of logical types (timestamp, date, time, decimal) is supported.","triggerScenarios":"Writing Avro GenericRecords with a field whose schema has a logicalType not in LOGICAL_TYPE_ENCODERS (e.g. custom logical types, uuid, duration) to BigQuery via Storage API","commonSituations":"Avro schemas generated by tools that attach custom logical types (Confluent schema registry, Avro 1.9+ logical types like uuid), or decimal logical types with unsupported precision/scale combos.","solutions":["Remove or flatten the unsupported logical type from the Avro schema (use the underlying primitive type)","Pre-convert the value to a supported type (e.g. convert custom logical types to long/string) before writing","Check the supported encoder keys in AvroGenericRecordToStorageApiProto.LOGICAL_TYPE_ENCODERS and match your logical type name to one","Upgrade Beam — newer versions add support for more logical types"],"exampleFix":"// before\nSchema uuidField = LogicalTypes.uuid().addToSchema(Schema.create(Schema.Type.STRING));\n// after\nSchema uuidField = Schema.create(Schema.Type.STRING); // plain string","handlingStrategy":"validation","validationCode":"// Java\nSchema logicalTypeSchema = schema.getField(name).schema();\nLogicalType lt = logicalTypeSchema.getLogicalType();\nif (lt != null && !Set.of(\"timestamp-millis\",\"timestamp-micros\",\"date\",\"time-millis\",\"time-micros\",\"decimal\").contains(lt.getName())) {\n  throw new IllegalStateException(\"Unsupported logical type: \" + lt.getName());\n}","typeGuard":"// Java\nBiFunction<LogicalType, Object, Object> enc = LOGICAL_TYPE_ENCODERS.get(lt.getName());\nif (enc != null) { /* supported */ }","tryCatchPattern":"// Java\ntry {\n  return scalarToProtoValue(fieldSchema, type, value);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported logical type\")) {\n    // fall back to primitive conversion or skip field\n  }\n  throw e;\n}","preventionTips":["Restrict Avro logical types in your schemas to Beam's supported set","Flatten custom logical types to primitives before writing to BigQuery","Check LOGICAL_TYPE_ENCODERS keys in the Beam version you deploy"],"tags":["java","bigquery","avro","logical-type"],"backgroundTag":"unsupported-enum-value","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"}