apache/iceberg · error · IllegalStateException

Invalid Binary type found in ORC type attribute

Error message

Invalid Binary type found in ORC type attribute

What it means

ORC stores Iceberg binary-family types (binary, fixed(n)) in a BINARY column plus the ICEBERG_BINARY_TYPE_ATTRIBUTE. convertBinary switches on that attribute to produce Types.FixedType.ofLength or Types.BinaryType; any unrecognized value throws IllegalStateException('Invalid Binary type found in ORC type attribute').

Solutions

  1. Correct ICEBERG_BINARY_TYPE_ATTRIBUTE: remove it for Types.BinaryType, or set the expected fixed-length marker with a valid integer length for FixedType.
  2. Rewrite the ORC file using Iceberg's ORC writer so attributes are canonical.
  3. Align reader and writer Iceberg versions.
  4. If a fixed-length value fails to parse, verify the attribute string contains a valid numeric length.

Example fix

// before
ICEBERG_BINARY_TYPE_ATTRIBUTE = "fixed" // missing length
// after
ICEBERG_BINARY_TYPE_ATTRIBUTE = "fixed:16" // or remove for BinaryType
Defensive patterns

Strategy: validation

Validate before calling

String attr = orcBinary.getAttributeValue(ORCSchemaUtil.ICEBERG_BINARY_TYPE_ATTRIBUTE);
boolean binary = attr == null || ORCSchemaUtil.BINARY.equals(attr);
boolean fixed = attr != null && attr.startsWith("fixed") && parseLength(attr) > 0;
if (!binary && !fixed) { throw new IllegalArgumentException("Bad BINARY attribute: " + attr); }

Try / catch

try { schema = ORCSchemaUtil.convert(orcSchema); } catch (IllegalStateException e) { if (e.getMessage().contains("Invalid Binary type")) { fixBinaryAttribute(file); } else throw e; }

Prevention

When it happens

Trigger: OrcToIcebergVisitor.primitive → convertBinary on an ORC BINARY column whose ICEBERG_BINARY_TYPE_ATTRIBUTE is not one of the recognized values (fixed with a valid length, or binary/default).

Common situations: ORC files produced by external engines or custom forks with different attribute conventions; corrupted or truncated attribute values (e.g. missing length); writer/reader Iceberg version skew.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/af21894c12136bb7. Report an issue: GitHub.

Appendix: source

Thrown at orc/src/main/java/org/apache/iceberg/orc/OrcToIcebergVisitor.java:239

        binary.getAttributeValue(ORCSchemaUtil.ICEBERG_BINARY_TYPE_ATTRIBUTE);
    ORCSchemaUtil.BinaryType binaryType =
        binaryAttributeValue == null
            ? ORCSchemaUtil.BinaryType.BINARY
            : ORCSchemaUtil.BinaryType.valueOf(binaryAttributeValue);
    switch (binaryType) {
      case UUID:
        builder.ofType(Types.UUIDType.get());
        break;
      case FIXED:
        int fixedLength =
            Integer.parseInt(binary.getAttributeValue(ORCSchemaUtil.ICEBERG_FIELD_LENGTH));
        builder.ofType(Types.FixedType.ofLength(fixedLength));
        break;
      case BINARY:
        builder.ofType(Types.BinaryType.get());
        break;
      default:
        throw new IllegalStateException("Invalid Binary type found in ORC type attribute");
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)