{"record":{"id":"aca12b3e99b2b617","repo":"apache/iceberg","slug":"unsupported-yearmonthintervaltype-aca12b","errorCode":null,"errorMessage":"Unsupported YearMonthIntervalType.","messagePattern":"Unsupported YearMonthIntervalType\\.","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkTypeVisitor.java","lineNumber":43,"sourceCode":"import org.apache.flink.table.types.logical.NullType;\nimport org.apache.flink.table.types.logical.RawType;\nimport org.apache.flink.table.types.logical.StructuredType;\nimport org.apache.flink.table.types.logical.SymbolType;\nimport org.apache.flink.table.types.logical.YearMonthIntervalType;\nimport org.apache.flink.table.types.logical.ZonedTimestampType;\n\npublic abstract class FlinkTypeVisitor<T> implements LogicalTypeVisitor<T> {\n\n  // ------------------------- Unsupported types ------------------------------\n\n  @Override\n  public T visit(ZonedTimestampType zonedTimestampType) {\n    throw new UnsupportedOperationException(\"Unsupported ZonedTimestampType.\");\n  }\n\n  @Override\n  public T visit(YearMonthIntervalType yearMonthIntervalType) {\n    throw new UnsupportedOperationException(\"Unsupported YearMonthIntervalType.\");\n  }\n\n  @Override\n  public T visit(DayTimeIntervalType dayTimeIntervalType) {\n    throw new UnsupportedOperationException(\"Unsupported DayTimeIntervalType.\");\n  }\n\n  @Override\n  public T visit(DistinctType distinctType) {\n    throw new UnsupportedOperationException(\"Unsupported DistinctType.\");\n  }\n\n  @Override\n  public T visit(StructuredType structuredType) {\n    throw new UnsupportedOperationException(\"Unsupported StructuredType.\");\n  }\n\n  @Override","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkTypeVisitor.java#L25-L61","documentation":"FlinkTypeVisitor throws UnsupportedOperationException for YearMonthIntervalType because Iceberg has no corresponding interval type. Interval columns cannot be represented in an Iceberg schema, so conversion fails by design.","triggerScenarios":"Schema conversion (FlinkSchemaUtil.toIcebergSchema or similar) encountering a Flink column of type INTERVAL YEAR TO MONTH, dispatching to visit(YearMonthIntervalType).","commonSituations":"Tables carrying duration/tenure columns typed as INTERVAL YEAR TO MONTH; upstream systems (e.g. Oracle-style schemas) ported to Flink with native interval types.","solutions":["Replace the interval column with an integral type like INT (number of months) or BIGINT.","Cast the interval to a numeric representation before writing to Iceberg.","Subclass FlinkTypeVisitor and override visit(YearMonthIntervalType) with a custom mapping.","Store as a string if the interval must be preserved verbatim."],"exampleFix":"// before\ncol 'tenure' INTERVAL YEAR TO MONTH\n\n// after\ncol 'tenure_months' INT","handlingStrategy":"validation","validationCode":"for (Column col : resolvedSchema.getColumns()) {\n  if (col.getDataType().getLogicalType() instanceof YearMonthIntervalType) {\n    throw new IllegalArgumentException(\"Column '\" + col.getName() + \"' uses INTERVAL YEAR TO MONTH; use INT/BIGINT months\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  Schema s = FlinkSchemaUtil.toIcebergSchema(flinkSchema);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"YearMonthIntervalType\")) {\n    // replace interval columns with integer month counts\n  } else {\n    throw e;\n  }\n}","preventionTips":["Avoid INTERVAL types in persisted table schemas; use integer month/year counts.","Pre-validate schemas before creating Iceberg-backed tables.","Document that intervals are not part of the Iceberg type system."],"tags":["flink","type-mapping","interval","unsupported"],"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"}