apache/iceberg · error · java.lang.UnsupportedOperationException

${this.getClass()} does not implement getMap

Error message

${this.getClass()} does not implement getMap

What it means

ConstantColumnVector (vectorized Spark reads) returns one constant value for all rows and implements only scalar accessors plus getDecimal; getMap is intentionally not implemented, so calling it throws UnsupportedOperationException. A map-valued constant column cannot be represented by this vector.

Source

Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/ConstantColumnVector.java:107

  @Override
  public float getFloat(int rowId) {
    return (float) constant;
  }

  @Override
  public double getDouble(int rowId) {
    return (double) constant;
  }

  @Override
  public ColumnarArray getArray(int rowId) {
    throw new UnsupportedOperationException(this.getClass() + " does not implement getArray");
  }

  @Override
  public ColumnarMap getMap(int ordinal) {
    throw new UnsupportedOperationException(this.getClass() + " does not implement getMap");
  }

  @Override
  public Decimal getDecimal(int rowId, int precision, int scale) {
    return (Decimal) constant;
  }

  @Override
  public UTF8String getUTF8String(int rowId) {
    return (UTF8String) constant;
  }

  @Override
  public byte[] getBinary(int rowId) {
    return (byte[]) constant;
  }

  @Override

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Move map-typed constant projections out of the scan (apply withColumn after reading the table)
  2. Disable vectorized reads: spark.sql.iceberg.vectorization.enabled=false
  3. Upgrade the Iceberg runtime to a version with broader constant-vector support
  4. Rewrite the query so the map column originates from data files, not a constant

Example fix

// before: SELECT map('k',1) AS m, * FROM iceberg_table
// after:
val df = spark.read.format("iceberg").load("db.table").withColumn("m", map(lit("k"), lit(1)))
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure projected constants are scalar-only; move map-typed constants outside the scan

Try / catch

try {
  df.collect();
} catch (UnsupportedOperationException e) {
  if (e.getMessage().endsWith("does not implement getMap")) {
    // recompute the map column post-scan or disable vectorization
  } else throw e;
}

Prevention

When it happens

Trigger: A vectorized Spark read where Spark calls getMap on a column materialized as ConstantColumnVector — e.g. a constant-folded map literal or a map-typed metadata column pushed into the constant vector path.

Common situations: Queries projecting map-typed literals or constant map columns alongside an Iceberg scan with vectorization enabled; optimizer folding map expressions into the scan's constant columns.

Related errors


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