{"record":{"id":"bbf0b67aebadb5df","repo":"apache/iceberg","slug":"unknown-position-pos-expected-0-base-type-f","errorCode":null,"errorMessage":"Unknown position: ${pos} (expected 0-${BASE_TYPE.fields().size() - 1})","messagePattern":"Unknown position: (.+?) \\(expected 0-(.+?)\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/BasePartitionStatistics.java","lineNumber":176,"sourceCode":"        return totalDataFileSizeInBytes;\n      case POSITION_DELETE_RECORD_COUNT_POSITION:\n        return positionDeleteRecordCount;\n      case POSITION_DELETE_FILE_COUNT_POSITION:\n        return positionDeleteFileCount;\n      case EQUALITY_DELETE_RECORD_COUNT_POSITION:\n        return equalityDeleteRecordCount;\n      case EQUALITY_DELETE_FILE_COUNT_POSITION:\n        return equalityDeleteFileCount;\n      case TOTAL_RECORD_COUNT_POSITION:\n        return totalRecordCount;\n      case LAST_UPDATED_AT_POSITION:\n        return lastUpdatedAt;\n      case LAST_UPDATED_SNAPSHOT_ID_POSITION:\n        return lastUpdatedSnapshotId;\n      case DV_COUNT_POSITION:\n        return dvCount;\n      default:\n        throw unknownPosition(pos);\n    }\n  }\n\n  @Override\n  protected <T> void internalSet(int pos, T value) {\n    if (value == null) {\n      return;\n    }\n\n    switch (pos) {\n      case PARTITION_POSITION:\n        this.partition = (StructLike) value;\n        break;\n      case SPEC_ID_POSITION:\n        this.specId = (int) value;\n        break;\n      case DATA_RECORD_COUNT_POSITION:\n        this.dataRecordCount = (long) value;","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/BasePartitionStatistics.java#L158-L194","documentation":"BasePartitionStatistics.internalGet(int pos) maps positional field indexes (0..BASE_TYPE.fields().size()-1) to partition-statistics field values. An out-of-range or unrecognized position falls through the switch and throws UnsupportedOperationException via unknownPosition(pos). This is an internal invariant violation, not a user-facing validation.","triggerScenarios":"Calling internalGet with a position >= number of schema fields in PartitionStatistics, e.g. from a StructLike accessor using a stale or foreign schema; a code path assuming extra fields that this class does not define.","commonSituations":"Reading partition statistics with code compiled against a different Iceberg spec version whose field layout differs; custom StructLike wrappers reusing wrong position constants.","solutions":["Use the position constants defined by the class (e.g. PARTITION_POSITION, SNAPSHOT_ID_POSITION) instead of hardcoding indexes","Align the reader's schema with the table's partition-statistics schema (refresh to the same Iceberg version)","Wrap access in a check: if (pos < BASE_TYPE.fields().size()) before calling"],"exampleFix":"// before\nrow.get(7, Object.class); // beyond known fields -> Unknown position: 7\n// after\nTypes.StructType type = PartitionStatistics.TYPE;\nif (7 < type.fields().size()) {\n  row.get(7, Object.class);\n}","handlingStrategy":"type-guard","validationCode":"if (pos < 0 || pos >= PartitionStatistics.TYPE.fields().size()) throw new IllegalArgumentException(\"bad pos\");","typeGuard":"boolean isValidPos(int pos) { return pos >= 0 && pos < PartitionStatistics.TYPE.fields().size(); }","tryCatchPattern":"try { return internalGet(pos); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith(\"Unknown position\")) { return null; } throw e; }","preventionTips":["Derive positions from the class's position constants, never literals","Keep reader and library versions aligned","Iterate Types.StructType.fields() when accessing generically"],"tags":["unsupported-operation","position","partition-statistics","structlike"],"backgroundTag":"index-out-of-range","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"}