{"record":{"id":"ece98ec122e0da39","repo":"apache/iceberg","slug":"cannot-handle","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/OrcSchemaVisitor.java","lineNumber":52,"sourceCode":"\n    List<TypeDescription> fields = schema.getChildren();\n    List<String> names = schema.getFieldNames();\n\n    return visitFields(fields, names, visitor);\n  }\n\n  public static <T> T visit(TypeDescription schema, OrcSchemaVisitor<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(schema, visitor);\n        } else {\n          return visitRecord(schema, visitor);\n        }\n\n      case UNION:\n        throw new UnsupportedOperationException(\"Cannot handle \" + schema);\n\n      case LIST:\n        final T elementResult;\n\n        TypeDescription element = schema.getChildren().get(0);\n        visitor.beforeElementField(element);\n        try {\n          elementResult = visit(element, visitor);\n        } finally {\n          visitor.afterElementField(element);\n        }\n        return visitor.list(schema, elementResult);\n\n      case MAP:\n        final T keyResult;\n        final T valueResult;\n\n        TypeDescription key = schema.getChildren().get(0);","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/orc/OrcSchemaVisitor.java#L34-L70","documentation":"OrcSchemaVisitor.visit walks an ORC TypeDescription tree and dispatches to visitor callbacks per node type. ORC UNION types have no Iceberg counterpart, so the visitor explicitly rejects them with UnsupportedOperationException. This happens before any visitor callback runs.","triggerScenarios":"Calling OrcSchemaVisitor.visit (directly, or via OrcMetrics.statsColumns, ID mappings, or ORC file read/write paths) on a schema, or reading an ORC file whose schema contains a UNION type.","commonSituations":"See trigger scenarios.","solutions":["Remove UNION columns from the ORC schema, or re-express them as structs with a tag field before the file is referenced by Iceberg.","Rewrite the ORC data with a union-free schema (e.g. via a Spark/Hive CTAS that flattens the union).","If the union is in an unrelated column, project it out in your read path so the visitor never sees that subtree, if the API used allows schema pruning before visiting."],"exampleFix":"// before: ORC schema with union<int,string>\n// after: struct with tag\ncase int(1) tag, oneof: struct<a: int, b: string>","handlingStrategy":"validation","validationCode":"boolean hasUnion = false; // pre-scan schema\norg.apache.orc.TypeDescription root = schema;\nif (root.getCategory() == TypeDescription.Category.UNION) hasUnion = true;\n// or check each declared column's category before visiting","typeGuard":null,"tryCatchPattern":"try { OrcSchemaVisitor.visit(schema, visitor); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith(\"Cannot handle\")) { rejectFile(schemaPath); } else throw e; }","preventionTips":["Reject ORC files with union columns at ingestion time","Prefer struct-with-tag designs over ORC unions when writing with external engines","Validate schemas with ORC tooling before registering files with Iceberg"],"tags":["orc","schema","union-type","unsupported"],"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"}