{"record":{"id":"2ff4a2858e7acfb4","repo":"apache/iceberg","slug":"unsupported-avro-type-schema-gettype-2ff4a2","errorCode":null,"errorMessage":"Unsupported Avro type '${schema.getType()}'.","messagePattern":"Unsupported Avro type '(.+?)'\\.","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/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/v2.1/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L218-L254","documentation":"AvroSchemaConverter.convertToTypeInfo throws this when the Avro schema contains a type the converter has no mapping for when building a Flink TypeInformation (e.g. RECORD handled separately but exotic/unexpected schema kinds fall through the switch). The Avro type name is included in the message.","triggerScenarios":"Converting an Avro schema whose top-level or nested type is not in the handled set (e.g. unexpected schema kind like RECURSIVE sentinel or unsupported wrappers) into TypeInformation.","commonSituations":"Schemas with unusual constructs (unions at unsupported positions, exotic logical types) passed to the TypeInformation-based (DataSet/DataStream legacy) API; version drift between writer schema features and converter support.","solutions":["Simplify the schema to supported Avro types (record, primitives, arrays, maps, nullable unions)","Use convertToDataType (Table API path) which supports a broader type surface than convertToTypeInfo","Upgrade Iceberg/Flink to a version handling the Avro type","Pre-transform the schema to replace the unsupported type"],"exampleFix":"// before: unsupported union nested type\n{\"type\":[\"int\",\"long\"]}\n// after\n{\"type\":\"long\"}","handlingStrategy":"validation","validationCode":"Schema s = new Schema.Parser().parse(schemaString);\nSet<Schema.Type> supported = EnumSet.of(Schema.Type.RECORD, Schema.Type.ENUM, Schema.Type.ARRAY,\n    Schema.Type.MAP, Schema.Type.UNION, Schema.Type.FIXED, Schema.Type.STRING, Schema.Type.BOOLEAN,\n    Schema.Type.INT, Schema.Type.LONG, Schema.Type.FLOAT, Schema.Type.DOUBLE, Schema.Type.BYTES, Schema.Type.NULL);\nDeque<Schema> stack = new ArrayDeque<>(List.of(s));\nwhile (!stack.isEmpty()) {\n  Schema cur = stack.pop();\n  if (!supported.contains(cur.getType())) throw new IllegalStateException(\"Unsupported Avro type: \" + cur.getType());\n  cur.getFields().forEach(f -> stack.push(f.schema()));\n}","typeGuard":null,"tryCatchPattern":"try {\n  TypeInformation<?> ti = AvroSchemaConverter.convertToTypeInfo(schema, false);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported Avro type\")) {\n    // use convertToDataType or transform the schema\n  } else { throw e; }\n}","preventionTips":["Prefer convertToDataType (Table API) for broader type coverage","Avoid exotic Avro constructs in schemas destined for TypeInformation conversion","Upgrade Iceberg when using newer Avro schema features","Validate nested schema types before conversion"],"tags":["flink","avro","unsupported-type","schema"],"backgroundTag":"unsupported-operation","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"}