{"record":{"id":"a7017c4b32dd768b","repo":"apache/iceberg","slug":"unsupported-type-short","errorCode":null,"errorMessage":"Unsupported type - short","messagePattern":"Unsupported type - short","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/IcebergArrowColumnVector.java","lineNumber":95,"sourceCode":"\n  @Override\n  public boolean isNullAt(int rowId) {\n    return nullabilityHolder.isNullAt(rowId) == 1;\n  }\n\n  @Override\n  public boolean getBoolean(int rowId) {\n    return accessor.getBoolean(rowId);\n  }\n\n  @Override\n  public byte getByte(int rowId) {\n    throw new UnsupportedOperationException(\"Unsupported type - byte\");\n  }\n\n  @Override\n  public short getShort(int rowId) {\n    throw new UnsupportedOperationException(\"Unsupported type - short\");\n  }\n\n  @Override\n  public int getInt(int rowId) {\n    return accessor.getInt(rowId);\n  }\n\n  @Override\n  public long getLong(int rowId) {\n    return accessor.getLong(rowId);\n  }\n\n  @Override\n  public float getFloat(int rowId) {\n    return accessor.getFloat(rowId);\n  }\n\n  @Override","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/IcebergArrowColumnVector.java#L77-L113","documentation":"Iceberg's Arrow-backed column vector for Spark's vectorized reader does not implement getShort for the underlying accessor. Any code path that reads a short column value row-wise throws UnsupportedOperationException. Shorts must be read via getInt (upcast) by the caller.","triggerScenarios":"Calling IcebergShortColumnVector.getShort(rowId) on a vectorized batch read of a Spark ShortType/iceberg int-with-short-source column; typically triggered inside Spark's ColumnarBatch row access when an expression requests a short primitive directly.","commonSituations":"Custom Spark expressions or UDFs consuming a columnar batch that call getShort; Spark code paths (e.g. certain cast/aggregate operators) that assume short column vectors support getShort, while Iceberg only exposes the value as an int accessor.","solutions":["Read the value with getInt(rowId) instead and cast to short: (short) vec.getInt(rowId)","Disable vectorized reads for the scan (set read.arrow.vectorized or spark.sql.iceberg.vectorized-enabled=false) so rows are read via the non-vectorized path","If this occurs inside Spark internals, check whether the Spark expression supports columnar execution and mark the column/expr non-columnar or upgrade Iceberg/Spark versions"],"exampleFix":"// before\nshort v = vec.getShort(rowId);\n// after\nshort v = (short) vec.getInt(rowId);","handlingStrategy":"try-catch","validationCode":"// Check the vector type before row access\nif (vector.dataType() == DataTypes.ShortType) {\n  int v = ((IcebergArrowColumnVector) vector).getInt(rowId); // shorts are exposed as ints\n}","typeGuard":"boolean supportsShort(ColumnVector v) { return !(v instanceof IcebergArrowColumnVector); }","tryCatchPattern":"try {\n  s = vec.getShort(rowId);\n} catch (UnsupportedOperationException e) {\n  s = (short) vec.getInt(rowId);\n}","preventionTips":["Never call getShort on Iceberg Arrow column vectors; use getInt and narrow","Prefer reading ShortType columns through Spark's row accessors which upcast to int","Test custom expressions against Iceberg columnar batches before deploying"],"tags":["spark","vectorized-reader","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}