apache/iceberg · error · IllegalArgumentException

Duplicate id:

Error message

Duplicate id: 

What it means

CompareSchemasVisitor.Result builds a BY_ID lookup map in its static initializer and throws IllegalArgumentException if two enum constants share the same numeric id. This is an internal invariant check — users never cause it directly; it indicates a bug or binary-mixing in the Iceberg code itself.

Solutions

  1. Ensure a single, unmodified iceberg-flink/iceberg-core jar set is on the classpath (remove duplicate/shaded copies)
  2. If running a patched build, restore the original enum ids so each Result has a unique id
  3. Report upstream if a released Iceberg version reproduces this — it is an internal invariant violation

Example fix

// before
enum Result {
  SAME(0), DIFFERENT(0); // duplicate id
// after
enum Result {
  SAME(0), DIFFERENT(1);
Defensive patterns

Strategy: validation

Validate before calling

// Classpath sanity check before job submission
Set<String> copies = new LinkedHashSet<>();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
for (String jar : System.getProperty("java.class.path").split(File.pathSeparator)) {
  if (jar.contains("iceberg-flink-runtime") && !copies.add(new File(jar).getName())) {
    throw new IllegalStateException("multiple iceberg-flink-runtime jars on classpath: " + copies);
  }
}

Prevention

When it happens

Trigger: Loading a modified/duplicated CompareSchemasVisitor class where two Result constants have equal ids — practically only from code changes or classpath conflicts loading two versions of the class.

Common situations: Patched Iceberg jars on the classpath; custom forks; mixing iceberg-flink-runtime versions across the job classpath so conflicting definitions load.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/CompareSchemasVisitor.java:284

      if (listField != null) {
        return listField.type().asListType().fields().get(0).fieldId();
      }

      return null;
    }
  }

  public enum Result {
    SAME(0),
    DATA_CONVERSION_NEEDED(1),
    SCHEMA_UPDATE_NEEDED(2);

    private static final Map<Integer, Result> BY_ID = Maps.newHashMap();

    static {
      for (Result e : Result.values()) {
        if (BY_ID.put(e.id, e) != null) {
          throw new IllegalArgumentException("Duplicate id: " + e.id);
        }
      }
    }

    private final int id;

    Result(int id) {
      this.id = id;
    }

    private Result merge(Result other) {
      return BY_ID.get(Math.max(this.id, other.id));
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)