{"record":{"id":"0c54446bf19bbea6","repo":"apache/beam","slug":"unsupported-type-elementtype-gettype","errorCode":null,"errorMessage":"Unsupported type <elementType.getType()>","messagePattern":"Unsupported type <elementType\\.getType\\(\\)>","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/AvroGenericRecordToStorageApiProto.java","lineNumber":416,"sourceCode":"        }\n        break;\n      default:\n        elementType = TypeWithNullability.create(schema).getType();\n        if (TIMESTAMP_NANOS_LOGICAL_TYPE.equals(elementType.getProp(\"logicalType\"))) {\n          builder = builder.setType(TableFieldSchema.Type.TIMESTAMP);\n          builder.setTimestampPrecision(\n              Int64Value.newBuilder().setValue(PICOSECOND_PRECISION).build());\n          break;\n        } else {\n          Optional<LogicalType> logicalType =\n              Optional.ofNullable(LogicalTypes.fromSchema(elementType));\n          @Nullable\n          TableFieldSchema.Type primitiveType =\n              logicalType\n                  .flatMap(AvroGenericRecordToStorageApiProto::logicalTypes)\n                  .orElse(PRIMITIVE_TYPES.get(elementType.getType()));\n          if (primitiveType == null) {\n            throw new RuntimeException(\"Unsupported type \" + elementType.getType());\n          }\n          // a scalar will be required by default, if defined as part of union then\n          // caller will set nullability requirements\n          builder = builder.setType(primitiveType);\n          // parametrized types\n          if (logicalType.isPresent() && logicalType.get().getName().equals(\"decimal\")) {\n            LogicalTypes.Decimal decimal = (LogicalTypes.Decimal) logicalType.get();\n            int precision = decimal.getPrecision();\n            int scale = decimal.getScale();\n            if (!(precision == 38 && scale == 9) // NUMERIC\n                && !(precision == 77 && scale == 38) // BIGNUMERIC\n            ) {\n              // parametrized type\n              builder = builder.setPrecision(precision);\n              if (scale != 0) {\n                builder = builder.setScale(scale);\n              }\n            }","sourceCodeStart":398,"sourceCodeEnd":434,"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#L398-L434","documentation":"fieldDescriptorFromAvroField maps Avro types to BigQuery TableFieldSchema types; when an Avro logical or primitive type has no mapping (PRIMITIVE_TYPES lookup returns null and no logical-type mapping applies), it throws RuntimeException 'Unsupported type X'.","triggerScenarios":"An Avro schema with a logical type not in the logicalTypes map (e.g. an exotic or custom logical type) whose underlying primitive also has no PRIMITIVE_TYPES entry.","commonSituations":"Producers using newer Avro logical types (duration, custom decimals) that this converter does not recognize; version mismatch between writer schema and converter support.","solutions":["Change the Avro field to a supported type or standard logical type (e.g. decimal with proper precision/scale)","Update Beam to a version whose logicalTypes map supports the type","Pre-convert unsupported types to strings/bytes in the Avro schema"],"exampleFix":"// before\n{\"type\":\"bytes\",\"logicalType\":\"duration\"} // unsupported logical type\n// after\n{\"type\":\"long\"} // or a supported logical type like decimal","handlingStrategy":"validation","validationCode":"for (org.apache.avro.Schema.Field f : avroSchema.getFields()) { org.apache.avro.Schema t = unwrapUnion(f.schema()); if (t.getLogicalType() != null && !SUPPORTED_LOGICALS.contains(t.getLogicalType().getName())) throw new IllegalStateException(\"unsupported logical type \" + t.getLogicalType().getName() + \" on \" + f.name()); }","typeGuard":"boolean avroTypeSupported(org.apache.avro.Schema s) { org.apache.avro.LogicalType lt = s.getLogicalType(); return lt == null || Set.of(\"decimal\",\"date\",\"time-millis\",\"timestamp-millis\").contains(lt.getName()); }","tryCatchPattern":"try { protoTableSchema = ...protoTableSchemaFromAvroSchema(...); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Unsupported type\")) { normalizeSchemaAndRetry(); } else throw e; }","preventionTips":["Stick to logical types known to be supported by the Beam version in use","Pin writer schemas; review when producers upgrade Avro logical types"],"tags":["java","apache-beam","bigquery","avro","unsupported-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-14T11:17:12.474Z"}