apache/iceberg · error · IllegalArgumentException

Can't handle %s

Error message

Can't handle %s

What it means

OrcToIcebergVisitor.primitive maps each ORC primitive TypeDescription to an Iceberg type via convertXxx helpers keyed by the ICEBERG_LONG_TYPE_ATTRIBUTE / ICEBERG_BINARY_TYPE_ATTRIBUTE attributes. When the primitive's ORC category falls through all handled cases (including attribute-driven LONG/BINARY conversion), it throws IllegalArgumentException naming the ORC type. It means this ORC primitive has no Iceberg mapping in this code path.

Source

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

        }

        break;
      case TIMESTAMP_INSTANT:
        String tsUnit = primitive.getAttributeValue(ORCSchemaUtil.TIMESTAMP_UNIT);
        if (tsUnit == null || ORCSchemaUtil.MICROS.equalsIgnoreCase(tsUnit)) {
          builder.ofType(Types.TimestampType.withZone());
        } else if (tsUnit.equalsIgnoreCase(ORCSchemaUtil.NANOS)) {
          builder.ofType(Types.TimestampNanoType.withZone());
        } else {
          throw new IllegalStateException(String.format("Invalid Timestamp type unit: %s", tsUnit));
        }

        break;
      case DECIMAL:
        builder.ofType(Types.DecimalType.of(primitive.getPrecision(), primitive.getScale()));
        break;
      default:
        throw new IllegalArgumentException("Can't handle " + primitive);
    }

    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());

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Upgrade iceberg-orc so the converter knows the primitive type in question.
  2. Rewrite the ORC file using Iceberg's writer with a supported schema.
  3. Change the column's ORC type to a supported equivalent (e.g. STRING instead of an exotic category).
  4. If this is a custom attribute-driven mapping, ensure ICEBERG_LONG_TYPE_ATTRIBUTE / ICEBERG_BINARY_TYPE_ATTRIBUTE values are valid so convertLong/convertBinary do not fall through.

Example fix

// before: unsupported ORC primitive category
// after: rewrite column as a supported type
column: interval -> string  // store as string, or upgrade Iceberg
Defensive patterns

Strategy: try-catch

Validate before calling

// check the primitive category is mappable before conversion
switch (primitive.getCategory()) { case BOOLEAN: case BYTE: case INT: case LONG: case FLOAT: case DOUBLE: case STRING: case VARCHAR: case CHAR: case DATE: case TIMESTAMP: case DECIMAL: case BINARY: break; default: throw new IllegalArgumentException("Unmapped ORC primitive: " + primitive); }

Try / catch

try { icebergSchema = ORCSchemaUtil.convert(orcSchema); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Can't handle")) { rewriteFileWithSupportedTypes(file); } else throw e; }

Prevention

When it happens

Trigger: Visiting an ORC schema whose primitive category is not one of the handled types (BOOLEAN, INT, LONG-with-attribute, FLOAT, DOUBLE, STRING, VARCHAR, CHAR, DATE, TIME-with-attribute, TIMESTAMP, TIMESTAMP_INSTANT, DECIMAL, BINARY-with-attribute...) — e.g. an unanticipated category or a LONG/BINARY whose attribute conversion helper receives an unexpected default.

Common situations: Reading ORC files written by external tools with exotic primitive usage; Iceberg version skew where a writer produced a type mapping the reader's converter does not know; corrupted type attributes causing fall-through.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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