{"record":{"id":"cf3398996234cbeb","repo":"apache/iceberg","slug":"invalid-long-type-found-in-orc-type-attribute","errorCode":null,"errorMessage":"Invalid Long type found in ORC type attribute","messagePattern":"Invalid Long type found in ORC type attribute","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"orc/src/main/java/org/apache/iceberg/orc/OrcToIcebergVisitor.java","lineNumber":215,"sourceCode":"    return Optional.of(builder.build());\n  }\n\n  private static void convertLong(TypeDescription primitive, Types.NestedField.Builder builder) {\n    String longAttributeValue =\n        primitive.getAttributeValue(ORCSchemaUtil.ICEBERG_LONG_TYPE_ATTRIBUTE);\n    ORCSchemaUtil.LongType longType =\n        longAttributeValue == null\n            ? ORCSchemaUtil.LongType.LONG\n            : ORCSchemaUtil.LongType.valueOf(longAttributeValue);\n    switch (longType) {\n      case TIME:\n        builder.ofType(Types.TimeType.get());\n        break;\n      case LONG:\n        builder.ofType(Types.LongType.get());\n        break;\n      default:\n        throw new IllegalStateException(\"Invalid Long type found in ORC type attribute\");\n    }\n  }\n\n  private static void convertBinary(TypeDescription binary, Types.NestedField.Builder builder) {\n    String binaryAttributeValue =\n        binary.getAttributeValue(ORCSchemaUtil.ICEBERG_BINARY_TYPE_ATTRIBUTE);\n    ORCSchemaUtil.BinaryType binaryType =\n        binaryAttributeValue == null\n            ? ORCSchemaUtil.BinaryType.BINARY\n            : ORCSchemaUtil.BinaryType.valueOf(binaryAttributeValue);\n    switch (binaryType) {\n      case UUID:\n        builder.ofType(Types.UUIDType.get());\n        break;\n      case FIXED:\n        int fixedLength =\n            Integer.parseInt(binary.getAttributeValue(ORCSchemaUtil.ICEBERG_FIELD_LENGTH));\n        builder.ofType(Types.FixedType.ofLength(fixedLength));","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/orc/OrcToIcebergVisitor.java#L197-L233","documentation":"ORC stores Iceberg long-family types (long, time) in a plain LONG column plus the ICEBERG_LONG_TYPE_ATTRIBUTE attribute. convertLong switches on that attribute; only the known values (time, none/long) are mapped. Any other attribute value throws IllegalStateException('Invalid Long type found in ORC type attribute').","triggerScenarios":"OrcToIcebergVisitor.primitive → convertLong on an ORC LONG column whose ORCSchemaUtil.ICEBERG_LONG_TYPE_ATTRIBUTE is set to a value other than the recognized tokens (e.g. neither empty/long nor time).","commonSituations":"ORC files written by other engines or custom forks that used the LONG attribute differently; hand-edited or corrupted type attributes; version skew between writer and reader Iceberg releases.","solutions":["Fix the ICEBERG_LONG_TYPE_ATTRIBUTE to a recognized value ('time' for TimeType, or remove it for plain long) and rewrite the file.","Rewrite the ORC data through Iceberg so the attribute is written canonically.","Upgrade Iceberg versions to match the writer's attribute convention.","Inspect attributes with ORC metadata tooling to identify the offending value before rewriting."],"exampleFix":"// before\nICEBERG_LONG_TYPE_ATTRIBUTE = \"bigint\" // unrecognized\n// after\nICEBERG_LONG_TYPE_ATTRIBUTE = \"time\" // or remove attribute for LongType","handlingStrategy":"validation","validationCode":"String attr = orcLong.getAttributeValue(ORCSchemaUtil.ICEBERG_LONG_TYPE_ATTRIBUTE);\nboolean ok = attr == null || attr.isEmpty() || ORCSchemaUtil.TIME.equalsIgnoreCase(attr);\nif (!ok) { throw new IllegalArgumentException(\"Bad LONG attribute: \" + attr); }","typeGuard":null,"tryCatchPattern":"try { schema = ORCSchemaUtil.convert(orcSchema); } catch (IllegalStateException e) { if (e.getMessage().contains(\"Invalid Long type\")) { fixLongAttribute(file); } else throw e; }","preventionTips":["Only set ICEBERG_LONG_TYPE_ATTRIBUTE to Iceberg's own constants","Strip foreign type attributes from externally produced ORC files","Inspect ORC user metadata with orc-tools before ingesting"],"tags":["orc","long-type","type-attribute","schema-conversion"],"backgroundTag":"invalid-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}