{"record":{"id":"2ddbdbe80e0736e2","repo":"apache/iceberg","slug":"unsupported-avro-type-schema-gettype","errorCode":null,"errorMessage":"Unsupported Avro type '${schema.getType()}'.","messagePattern":"Unsupported Avro type '(.+?)'\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java","lineNumber":236,"sourceCode":"              || (schema.getLogicalType() != null\n                  && schema.getLogicalType().getName().equals(\"local-timestamp-nanos\"))) {\n            return Types.LOCAL_DATE_TIME;\n          } else if (schema.getLogicalType() == LogicalTypes.timeMicros()\n              || schema.getLogicalType() == LogicalTypes.timeMillis()) {\n            return Types.SQL_TIME;\n          }\n        }\n        return Types.LONG;\n      case FLOAT:\n        return Types.FLOAT;\n      case DOUBLE:\n        return Types.DOUBLE;\n      case BOOLEAN:\n        return Types.BOOLEAN;\n      case NULL:\n        return Types.VOID;\n    }\n    throw new IllegalArgumentException(\"Unsupported Avro type '\" + schema.getType() + \"'.\");\n  }\n\n  /**\n   * Converts an Avro schema string into a nested row structure with deterministic field order and\n   * data types that are compatible with Flink's Table &amp; SQL API.\n   *\n   * @param avroSchemaString Avro schema definition string\n   * @return data type matching the schema\n   */\n  public static DataType convertToDataType(String avroSchemaString) {\n    return convertToDataType(avroSchemaString, true);\n  }\n\n  /**\n   * Converts an Avro schema string into a nested row structure with deterministic field order and\n   * data types that are compatible with Flink's Table &amp; SQL API.\n   *\n   * @param avroSchemaString Avro schema definition string","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L218-L254","documentation":"The private convertToTypeInfo(Schema, boolean) maps Avro schema types to Flink TypeInformation. Types with no mapping (FIXED, BYTES beyond handled cases, unions, enums, etc. depending on the switch) fall through the switch and hit a final throw of IllegalArgumentException(\"Unsupported Avro type '<type>'.\").","triggerScenarios":"AvroSchemaConverter.convertToTypeInfo(schema, legacyTimestampMapping) where schema.getType() is not one of RECORD/ARRAY/MAP/STRING/INT/LONG/FLOAT/DOUBLE/BOOLEAN/NULL handled by the switch — e.g. UNION, ENUM, FIXED, BYTES.","commonSituations":"Schemas containing Avro unions (this legacy TypeInformation path doesn't handle them), enums, or logical types; schemas generated by tools that emit ENUM/FIXED by default; passing a top-level non-record schema.","solutions":["Rewrite the schema to use only supported types: replace ENUM with STRING, FIXED with fixed-size BYTES equivalent, and unions with nullable wrappers only where the converter supports them.","Use convertToDataType (the newer DataType API) instead of convertToTypeInfo — it covers more Avro types.","For unions, restructure the field as nullable single type; for records containing unions, change the source schema or pre-convert the data.","Check which type failed (in the message) and consult the switch in AvroSchemaConverter for the supported set."],"exampleFix":"// before\nSchema enumSchema = Schema.createEnum(\"Color\", null, null, Arrays.asList(\"RED\", \"BLUE\"));\nAvroSchemaConverter.convertToTypeInfo(enumSchema, false); // throws Unsupported Avro type 'ENUM'\n// after\nSchema strSchema = Schema.create(Schema.Type.STRING);\nAvroSchemaConverter.convertToTypeInfo(strSchema, false); // Types.STRING","handlingStrategy":"validation","validationCode":"static final Set<Schema.Type> SUPPORTED = EnumSet.of(RECORD, ARRAY, MAP, STRING, INT, LONG, FLOAT, DOUBLE, BOOLEAN, NULL);\n// walk schema recursively before calling convertToTypeInfo\nstatic void validate(Schema s) {\n  switch (s.getType()) {\n    case RECORD: s.getFields().forEach(f -> validate(f.schema())); break;\n    case ARRAY: validate(s.getElementType()); break;\n    case MAP: validate(s.getValueType()); break;\n    default:\n      if (!SUPPORTED.contains(s.getType())) throw new IllegalStateException(\"Unsupported: \" + s.getType());\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  AvroSchemaConverter.convertToTypeInfo(schema, false);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported Avro type\")) {\n    // fall back to convertToDataType or rewrite the schema\n  } else throw e;\n}","preventionTips":["Prefer convertToDataType (newer DataType API) over the legacy TypeInformation path.","Restrict source schemas to primitives, record, array, map, and [T, null] unions.","Replace ENUM and FIXED fields with STRING/BYTES at schema-generation time."],"tags":["avro","flink","unsupported-type","schema"],"backgroundTag":"unsupported-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}