{"record":{"id":"7c1a5b2a8c687d63","repo":"apache/iceberg","slug":"expected-one-and-same-orc-type-for-list-elements","errorCode":null,"errorMessage":"Expected one (and same) ORC type for list elements, got: ","messagePattern":"Expected one \\(and same\\) ORC type for list elements, got: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcValueWriters.java","lineNumber":137,"sourceCode":"  }\n\n  private static class Decimal38Writer implements OrcValueWriter<Decimal> {\n\n    @Override\n    public void nonNullWrite(int rowId, Decimal decimal, ColumnVector output) {\n      ((DecimalColumnVector) output)\n          .vector[rowId].set(HiveDecimal.create(decimal.toJavaBigDecimal()));\n    }\n  }\n\n  private static class ListWriter<T> implements OrcValueWriter<ArrayData> {\n    private final OrcValueWriter<T> writer;\n    private final SparkOrcWriter.FieldGetter<T> fieldGetter;\n\n    @SuppressWarnings(\"unchecked\")\n    ListWriter(OrcValueWriter<T> writer, List<TypeDescription> orcTypes) {\n      if (orcTypes.size() != 1) {\n        throw new IllegalArgumentException(\n            \"Expected one (and same) ORC type for list elements, got: \" + orcTypes);\n      }\n      this.writer = writer;\n      this.fieldGetter =\n          (SparkOrcWriter.FieldGetter<T>) SparkOrcWriter.createFieldGetter(orcTypes.get(0));\n    }\n\n    @Override\n    public void nonNullWrite(int rowId, ArrayData value, ColumnVector output) {\n      ListColumnVector cv = (ListColumnVector) output;\n      // record the length and start of the list elements\n      cv.lengths[rowId] = value.numElements();\n      cv.offsets[rowId] = cv.childCount;\n      cv.childCount = (int) (cv.childCount + cv.lengths[rowId]);\n      // make sure the child is big enough\n      growColumnVector(cv.child, cv.childCount);\n      // Add each element\n      for (int e = 0; e < cv.lengths[rowId]; ++e) {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcValueWriters.java#L119-L155","documentation":"SparkOrcValueWriters.ListWriter expects exactly one ORC TypeDescription describing the list's element type, since ORC lists have a single child type. Receiving a list of TypeDescriptions whose size differs from 1 means the ORC schema and the writer wiring disagree. This IllegalArgumentException is an internal invariant check guarding schema/writer mismatch.","triggerScenarios":"Constructing a ListWriter where the ORC child types list for a list column does not contain exactly one entry, typically due to a corrupted or mismatched ORC schema passed into SparkOrcWriter.","commonSituations":"Custom writer wiring, ORC schema produced by a foreign/buggy writer, or version mismatches where the ORC file schema's list encoding differs from expected.","solutions":["Verify the ORC TypeDescription for the list column has a single child (element type).","Regenerate/rewrite the ORC schema with a standard writer.","Check that the schema passed to SparkOrcWriter matches the actual file schema.","Align Iceberg and ORC library versions."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"org.apache.orc.TypeDescription listType = schema.findSubtype(\"my_list\");\nif (listType.getChildren().size() != 1) {\n  throw new IllegalStateException(\"ORC list must have exactly one child type, got \" + listType.getChildren());\n}","typeGuard":"static boolean isWellFormedOrcList(org.apache.orc.TypeDescription t) {\n  return t.getCategory() == org.apache.orc.TypeDescription.Category.LIST && t.getChildren().size() == 1;\n}","tryCatchPattern":null,"preventionTips":["Write ORC with standard writers only","Verify ORC file schemas after external writes","Keep ORC library versions consistent"],"tags":["spark","orc","writer","schema-mismatch","internal-invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}