{"record":{"id":"3294c6be3fea2c9a","repo":"apache/beam","slug":"unexpected-avro-field-schema-type-s-for-field-named-s","errorCode":null,"errorMessage":"Unexpected Avro field schema type %s for field named %s","messagePattern":"Unexpected Avro field schema type (.+?) for field named (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java","lineNumber":467,"sourceCode":"          // ideally byte[] but TableRowJsonCoder encodes as String\n          return BaseEncoding.base64().encode(((ByteBuffer) v).array());\n        }\n      case STRING:\n        // SQL types STRING, DATETIME, GEOGRAPHY, JSON\n        // when not using logical type DATE, TIME too\n        return v.toString();\n      case ENUM:\n        // SQL types STRING\n        return v.toString();\n      case FIXED:\n        // SQL type BYTES\n        // ideally byte[] but TableRowJsonCoder encodes as String\n        return BaseEncoding.base64().encode(((ByteBuffer) v).array());\n      case RECORD:\n        // SQL types RECORD\n        return convertGenericRecordToTableRow((GenericRecord) v);\n      default:\n        throw new UnsupportedOperationException(\n            String.format(\"Unexpected Avro field schema type %s for field named %s\", type, name));\n    }\n  }\n\n  private static @Nullable Object convertNullableField(String name, Schema union, Object v) {\n    // NULLABLE fields are represented as an Avro Union of the corresponding type and \"null\".\n    verify(\n        union.getType() == Schema.Type.UNION,\n        \"Expected Avro schema type UNION, not %s, for BigQuery NULLABLE field %s\",\n        union.getType(),\n        name);\n    List<Schema> unionTypes = union.getTypes();\n    verify(\n        unionTypes.size() == 2,\n        \"BigQuery NULLABLE field %s should be an Avro UNION of NULL and another type, not %s\",\n        name,\n        union);\n","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java#L449-L485","documentation":"convertRequiredField converts an Avro GenericRecord value into a TableRow JSON value for a given Avro field schema type. When the Avro schema type is one it cannot map (anything outside the handled INT/LONG/FLOAT/DOUBLE/BOOLEAN/STRING/BYTES/ENUM/RECORD etc. cases), it throws UnsupportedOperationException with the type and field name.","triggerScenarios":"Reading BigQuery-exported Avro files whose field schema type falls through the switch — e.g. unexpected UNION reaching the required path, or exotic logical types — during GenericRecord to TableRow conversion in BigQueryIO read.","commonSituations":"Avro exports from BigQuery with new/unsupported logical types, or hand-crafted Avro schemas containing types like MAP/FIXED reaching this converter.","solutions":["Upgrade Beam to pick up support for the newer Avro logical type","Pre-transform the Avro record to convert unsupported fields to supported types","Inspect the field named in the message and adjust the BigQuery export to avoid that type"],"exampleFix":"// before\nSchema.Field.of(\"x\", Schema.FieldType.INT32) mapped from Avro INT with unsupported logical type\n// after\nExport/read with a supported type, e.g. cast the column to INTEGER/STRING in the query","handlingStrategy":"try-catch","validationCode":"for (Schema.Field f : record.getSchema().getFields()) { if (f.schema().getType() == Schema.Type.UNION || f.schema().getType() == Schema.Type.MAP) { /* transform or reject */ } }","typeGuard":"static boolean isConvertible(Schema.Type t) { return EnumSet.of(INT, LONG, FLOAT, DOUBLE, BOOLEAN, STRING, BYTES, ENUM, RECORD).contains(t); }","tryCatchPattern":"try { row = convertGenericRecordToTableRow(record); } catch (UnsupportedOperationException e) { log.warn(\"Skipping unsupported field\", e); }","preventionTips":["Pre-process Avro records to strip/convert unsupported types","Keep Beam current with BigQuery export logical types","Inspect export schemas before ingestion"],"tags":["java","apache-beam","avro","tablerow","conversion"],"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"}