{"record":{"id":"b13e18ee78027b61","repo":"apache/iceberg","slug":"this-getclass-does-not-implement-getarray","errorCode":null,"errorMessage":"${this.getClass()} does not implement getArray","messagePattern":"(.+?) does not implement getArray","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/ConstantColumnVector.java","lineNumber":102,"sourceCode":"\n  @Override\n  public long getLong(int rowId) {\n    return (long) constant;\n  }\n\n  @Override\n  public float getFloat(int rowId) {\n    return (float) constant;\n  }\n\n  @Override\n  public double getDouble(int rowId) {\n    return (double) constant;\n  }\n\n  @Override\n  public ColumnarArray getArray(int rowId) {\n    throw new UnsupportedOperationException(this.getClass() + \" does not implement getArray\");\n  }\n\n  @Override\n  public ColumnarMap getMap(int ordinal) {\n    throw new UnsupportedOperationException(this.getClass() + \" does not implement getMap\");\n  }\n\n  @Override\n  public Decimal getDecimal(int rowId, int precision, int scale) {\n    return (Decimal) constant;\n  }\n\n  @Override\n  public UTF8String getUTF8String(int rowId) {\n    return (UTF8String) constant;\n  }\n\n  @Override","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/ConstantColumnVector.java#L84-L120","documentation":"ConstantColumnVector is a Spark columnar vector that returns a single constant value for every row (used for metadata/constant-folded columns in vectorized reads). It implements scalar accessors (getBoolean, getInt, getDouble, getDecimal) but deliberately does not implement getArray, since a constant value cannot be an array in this design; calling getArray throws UnsupportedOperationException.","triggerScenarios":"A vectorized Spark read where a query invokes getArray on a column that was materialized as a ConstantColumnVector — e.g. a constant-folded expression or metadata column whose Spark type is an array type.","commonSituations":"Selecting an array-typed constant or metadata column (e.g. via metadata column projection or partition transforms producing constant arrays); Spark optimizer folding a literal array column into the constant vector path.","solutions":["Avoid projecting array-typed constants/metadata columns in vectorized reads; compute them outside the scan (e.g. with a post-scan select)","Disable vectorization: spark.sql.iceberg.vectorization.enabled=false","Upgrade Iceberg — newer versions may support constant arrays in vectorized reads","Restructure the query so the array column comes from actual data files rather than a constant source"],"exampleFix":"// before: SELECT array(1,2) AS a, * FROM iceberg_table (constant array hits vectorized scan)\n// after:\nval df = spark.read.format(\"iceberg\").load(\"db.table\")\ndf.withColumn(\"a\", array(lit(1), lit(2))) // constant added after the scan","handlingStrategy":"try-catch","validationCode":"// Avoid array-typed constants/metadata columns in vectorized scans:\n// if the projection includes a literal array, apply it after the read instead","typeGuard":null,"tryCatchPattern":"try {\n  df.collect();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().endsWith(\"does not implement getArray\")) {\n    // recompute the array column post-scan or disable vectorization\n  } else throw e;\n}","preventionTips":["Don't project array/map literals together with vectorized Iceberg scans; add them after the read","Keep constant-foldable expressions out of scan projections","Test vectorized reads (vectorization.enabled=true) with your full projection list"],"tags":["spark","vectorized-read","columnar","array"],"backgroundTag":"method-not-implemented","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}