{"record":{"id":"d56a25b1ad72969c","repo":"apache/iceberg","slug":"cannot-handle-d56a25","errorCode":null,"errorMessage":"Cannot handle ","messagePattern":"Cannot handle ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"orc/src/main/java/org/apache/iceberg/orc/OrcSchemaWithTypeVisitor.java","lineNumber":48,"sourceCode":"      org.apache.iceberg.Schema iSchema,\n      TypeDescription schema,\n      OrcSchemaWithTypeVisitor<T> visitor) {\n    return visit(iSchema.asStruct(), schema, visitor);\n  }\n\n  public static <T> T visit(\n      Type iType, TypeDescription schema, OrcSchemaWithTypeVisitor<T> visitor) {\n    switch (schema.getCategory()) {\n      case STRUCT:\n        String structType = schema.getAttributeValue(ORCSchemaUtil.ICEBERG_STRUCT_TYPE_ATTRIBUTE);\n        if (ORCSchemaUtil.VARIANT.equalsIgnoreCase(structType)) {\n          return visitVariant(iType != null ? iType.asVariantType() : null, schema, visitor);\n        } else {\n          return visitRecord(iType != null ? iType.asStructType() : null, schema, visitor);\n        }\n\n      case UNION:\n        throw new UnsupportedOperationException(\"Cannot handle \" + schema);\n\n      case LIST:\n        Types.ListType list = iType != null ? iType.asListType() : null;\n        return visitor.list(\n            list,\n            schema,\n            visit(list != null ? list.elementType() : null, schema.getChildren().get(0), visitor));\n\n      case MAP:\n        Types.MapType map = iType != null ? iType.asMapType() : null;\n        return visitor.map(\n            map,\n            schema,\n            visit(map != null ? map.keyType() : null, schema.getChildren().get(0), visitor),\n            visit(map != null ? map.valueType() : null, schema.getChildren().get(1), visitor));\n\n      default:\n        return visitor.primitive(iType != null ? iType.asPrimitiveType() : null, schema);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/orc/OrcSchemaWithTypeVisitor.java#L30-L66","documentation":"OrcSchemaWithTypeVisitor.visit maps an ORC TypeDescription tree (with its Iceberg Types counterpart) to visitor callbacks. ORC UNION types cannot be represented in Iceberg, so the visitor throws UnsupportedOperationException when it encounters one. Like the typeless OrcSchemaVisitor, this rejects the schema before any mapping is produced.","triggerScenarios":"Calling OrcSchemaWithTypeVisitor.visit (used by ORC-to-Iceberg schema conversion in ORCSchemaUtil and readers) on an ORC schema containing a UNION node.","commonSituations":"Converting an externally written ORC file schema to an Iceberg schema; reading ORC data files produced by Trino/Hive that contain union columns.","solutions":["Eliminate UNION types from the ORC schema (flatten to a struct with a discriminator/tag column) and rewrite the data.","Skip or prune union columns before conversion if the tooling allows selecting only needed columns.","Convert the file format to Parquet/Avro where the data model supports the equivalent of the union."],"exampleFix":"// before: uniontype<int,string>\n// after: struct<tag: int, int_val: int, str_val: string>","handlingStrategy":"validation","validationCode":"for (TypeDescription child : schema.getChildren()) { if (child.getCategory() == TypeDescription.Category.UNION) { throw new IllegalArgumentException(\"ORC union column not supported: \" + child); } }","typeGuard":null,"tryCatchPattern":"try { converted = OrcSchemaWithTypeVisitor.visit(icebergType, orcSchema, visitor); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith(\"Cannot handle\")) { logAndReject(orcSchema); } else throw e; }","preventionTips":["Flatten ORC unions into structs with a discriminator column at write time","Scan external ORC files for UNION categories before conversion","Keep conversion tooling and file writers on compatible Iceberg versions"],"tags":["orc","schema","union-type","iceberg-types"],"backgroundTag":"incompatible-source-type","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"}