apache/iceberg · error · IllegalStateException

Invalid Long type found in ORC type attribute

Error message

Invalid Long type found in ORC type attribute

What it means

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').

Solutions

  1. Fix the ICEBERG_LONG_TYPE_ATTRIBUTE to a recognized value ('time' for TimeType, or remove it for plain long) and rewrite the file.
  2. Rewrite the ORC data through Iceberg so the attribute is written canonically.
  3. Upgrade Iceberg versions to match the writer's attribute convention.
  4. Inspect attributes with ORC metadata tooling to identify the offending value before rewriting.

Example fix

// before
ICEBERG_LONG_TYPE_ATTRIBUTE = "bigint" // unrecognized
// after
ICEBERG_LONG_TYPE_ATTRIBUTE = "time" // or remove attribute for LongType
Defensive patterns

Strategy: validation

Validate before calling

String attr = orcLong.getAttributeValue(ORCSchemaUtil.ICEBERG_LONG_TYPE_ATTRIBUTE);
boolean ok = attr == null || attr.isEmpty() || ORCSchemaUtil.TIME.equalsIgnoreCase(attr);
if (!ok) { throw new IllegalArgumentException("Bad LONG attribute: " + attr); }

Try / catch

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

Prevention

When it happens

Trigger: 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).

Common situations: 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.

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/cf3398996234cbeb. Report an issue: GitHub.

Appendix: source

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

    return Optional.of(builder.build());
  }

  private static void convertLong(TypeDescription primitive, Types.NestedField.Builder builder) {
    String longAttributeValue =
        primitive.getAttributeValue(ORCSchemaUtil.ICEBERG_LONG_TYPE_ATTRIBUTE);
    ORCSchemaUtil.LongType longType =
        longAttributeValue == null
            ? ORCSchemaUtil.LongType.LONG
            : ORCSchemaUtil.LongType.valueOf(longAttributeValue);
    switch (longType) {
      case TIME:
        builder.ofType(Types.TimeType.get());
        break;
      case LONG:
        builder.ofType(Types.LongType.get());
        break;
      default:
        throw new IllegalStateException("Invalid Long type found in ORC type attribute");
    }
  }

  private static void convertBinary(TypeDescription binary, Types.NestedField.Builder builder) {
    String binaryAttributeValue =
        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));

View on GitHub (pinned to 86d9c8fc54)