{"record":{"id":"13571ef59652c9b1","repo":"apache/iceberg","slug":"unsupported-array-element-type-elementtype-13571e","errorCode":null,"errorMessage":"Unsupported array element type: \" + elementType","messagePattern":"Unsupported array element type: \" \\+ elementType","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/StructInternalRow.java","lineNumber":368,"sourceCode":"        return fillArray(\n            values,\n            array ->\n                (BiConsumer<Integer, Collection<?>>)\n                    (pos, list) ->\n                        array[pos] =\n                            collectionToArrayData(elementType.asListType().elementType(), list));\n      case MAP:\n        return fillArray(\n            values,\n            array ->\n                (BiConsumer<Integer, Map<?, ?>>)\n                    (pos, map) -> array[pos] = mapToMapData(elementType.asMapType(), map));\n      case VARIANT:\n        return fillArray(\n            values,\n            array -> (BiConsumer<Integer, Object>) (pos, v) -> array[pos] = toVariantVal(v));\n      default:\n        throw new UnsupportedOperationException(\"Unsupported array element type: \" + elementType);\n    }\n  }\n\n  private static VariantVal toVariantVal(Object value) {\n    if (value instanceof Variant) {\n      Variant variant = (Variant) value;\n      byte[] metadataBytes = new byte[variant.metadata().sizeInBytes()];\n      ByteBuffer metadataBuffer = ByteBuffer.wrap(metadataBytes).order(ByteOrder.LITTLE_ENDIAN);\n      variant.metadata().writeTo(metadataBuffer, 0);\n\n      byte[] valueBytes = new byte[variant.value().sizeInBytes()];\n      ByteBuffer valueBuffer = ByteBuffer.wrap(valueBytes).order(ByteOrder.LITTLE_ENDIAN);\n      variant.value().writeTo(valueBuffer, 0);\n\n      return new VariantVal(valueBytes, metadataBytes);\n    }\n\n    throw new UnsupportedOperationException(","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/StructInternalRow.java#L350-L386","documentation":"collectionToArrayData converts a collection of Iceberg values into a Spark ArrayData during column pruning/conversion. When the array's element Type is a Type Iceberg cannot map to Spark ArrayData (not in the handled cases), it throws UnsupportedOperationException naming the element type.","triggerScenarios":"Reading an Iceberg table column whose array element type is not one of the supported mappings (e.g. nested or exotic types reaching the default branch of collectionToArrayData).","commonSituations":"Reading tables written with newer or non-Spark writers containing array element types the Spark 4.1 integration doesn't map; mismatched schema assumptions after format version upgrades.","solutions":["Check the actual element type reported in the message and confirm it is a supported Iceberg type for your Spark version","Rewrite/re-serialize the column to a supported element type in the table","Upgrade the Iceberg Spark runtime to a version supporting that element type","Cast the column in SQL to a supported type in the read query"],"exampleFix":"// before\nSELECT unsupported_arr FROM iceberg_table\n// after\nSELECT transform(unsupported_arr, x -> cast(x as string)) AS arr FROM iceberg_table","handlingStrategy":"validation","validationCode":"if (Arrays.stream(schema.fields()).anyMatch(f ->\n    f.dataType() instanceof ArrayType && !isSupportedElementType((ArrayType) f.dataType()))) {\n  log.warn(\"Array element type not supported by StructInternalRow; cast or filter it out\");\n}","typeGuard":"static boolean isSupportedElementType(ArrayType t) {\n  return !(t.elementType() instanceof CalendarIntervalType);\n}","tryCatchPattern":"try { readArrayColumn(); } catch (UnsupportedOperationException e) {\n  log.error(\"Unsupported array element type: {}\", e.getMessage(), e);\n  // fall back to reading the column as string\n}","preventionTips":["Only write array element types your reader runtime supports","Pin identical Iceberg versions across writer and reader jobs","Cast exotic columns to supported types in read queries"],"tags":["spark","array","unsupported-type"],"backgroundTag":"unsupported-dtype","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"}