{"record":{"id":"3392514b45748ee4","repo":"apache/iceberg","slug":"unsupported-yearmonthintervaltype-339251","errorCode":null,"errorMessage":"Unsupported YearMonthIntervalType.","messagePattern":"Unsupported YearMonthIntervalType\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/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.2/flink/src/main/java/org/apache/iceberg/flink/FlinkTypeVisitor.java#L25-L61","documentation":"FlinkTypeVisitor.visit(YearMonthIntervalType) throws UnsupportedOperationException because Iceberg has no interval type; Flink's INTERVAL YEAR TO MONTH columns cannot be represented in an Iceberg schema.","triggerScenarios":"Schema conversion (FlinkTypeUtil.toIcebergType / FlinkSchemaUtil) over a Flink schema containing `INTERVAL YEAR TO MONTH` columns.","commonSituations":"Pipelines that read interval columns from relational sources (e.g. Oracle/Postgres date arithmetic results) and try to write them straight into Iceberg tables.","solutions":["Store the interval as a numeric or string column (e.g. total months as INT) in the Flink DDL.","Convert the interval to a duration/number of months before writing to Iceberg.","Override visit(YearMonthIntervalType) in a custom visitor if a project-specific encoding is required."],"exampleFix":"// before\ncolumn <INTERVAL YEAR TO MONTH> ivl;\n// after\ncolumn INT months_between; // populate via computed months value","handlingStrategy":"type-guard","validationCode":"if (dataType.getLogicalType() instanceof YearMonthIntervalType) {\n  throw new IllegalArgumentException(\"Convert INTERVAL YEAR TO MONTH to INT months before Iceberg write\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store intervals as numeric month counts, not INTERVAL types.","Check inferred types when joining interval-producing expressions into sink schemas."],"tags":["flink","type-mapping","interval"],"backgroundTag":"incompatible-source-type","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"}