{"record":{"id":"735fa8bb9d520635","repo":"apache/iceberg","slug":"unsupported-type-interval-735fa8","errorCode":null,"errorMessage":"Unsupported type: interval","messagePattern":"Unsupported type: interval","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/StructInternalRow.java","lineNumber":219,"sourceCode":"      return ByteBuffers.toByteArray((ByteBuffer) bytes);\n    } else if (bytes instanceof byte[]) {\n      return (byte[]) bytes;\n    } else {\n      throw new IllegalStateException(\n          \"Unknown type for binary field. Type name: \" + bytes.getClass().getName());\n    }\n  }\n\n  @Override\n  public BinaryView getBinaryView(int ordinal) {\n    return isNullAt(ordinal)\n        ? null\n        : toBinaryView(type.fields().get(ordinal).type(), getBinaryInternal(ordinal));\n  }\n\n  @Override\n  public CalendarInterval getInterval(int ordinal) {\n    throw new UnsupportedOperationException(\"Unsupported type: interval\");\n  }\n\n  @Override\n  public InternalRow getStruct(int ordinal, int numFields) {\n    return isNullAt(ordinal) ? null : getStructInternal(ordinal);\n  }\n\n  private InternalRow getStructInternal(int ordinal) {\n    return new StructInternalRow(\n        type.fields().get(ordinal).type().asStructType(), struct.get(ordinal, StructLike.class));\n  }\n\n  @Override\n  public ArrayData getArray(int ordinal) {\n    return isNullAt(ordinal) ? null : getArrayInternal(ordinal);\n  }\n\n  private ArrayData getArrayInternal(int ordinal) {","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/StructInternalRow.java#L201-L237","documentation":"StructInternalRow does not implement support for Spark's CalendarInterval type; getInterval unconditionally throws UnsupportedOperationException. Iceberg tables have no interval type, so intervals are simply not representable in an Iceberg row.","triggerScenarios":"Calling getInterval(ordinal) on a StructInternalRow, typically when Spark's vectorized/row reader framework attempts to decode an interval column against an Iceberg-backed row.","commonSituations":"Queries or datasets containing SQL interval expressions materialized through IcebergInternalRow wrappers; framework code calling all InternalRow accessors generically.","solutions":["Avoid selecting interval-typed expressions directly from Iceberg rows; cast them to a supported type (e.g. string or long months/days)","Compute intervals outside the Iceberg scan projection","If in Spark code, materialize the interval after converting to Spark's own row representation"],"exampleFix":"// before\nSELECT INTERVAL '1' DAY AS i FROM iceberg_table\n// after\nSELECT CAST(INTERVAL '1' DAY AS STRING) AS i FROM iceberg_table","handlingStrategy":"validation","validationCode":"for (StructField f : schema.fields()) {\n  if (f.dataType() instanceof CalendarIntervalType) {\n    throw new IllegalArgumentException(\"Interval columns are not supported by Iceberg rows\");\n  }\n}","typeGuard":"static boolean isInterval(DataType t) {\n  return t instanceof CalendarIntervalType;\n}","tryCatchPattern":"try {\n  row.getInterval(i);\n} catch (UnsupportedOperationException e) {\n  value = computeIntervalExternally(i);\n}","preventionTips":["Never project interval expressions directly from Iceberg scans","Cast intervals to string/numeric before selection","Check supported Iceberg data types before schema design"],"tags":["spark","unsupported-type","interval"],"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"}