{"record":{"id":"9c92d4694e3c3c64","repo":"apache/iceberg","slug":"unsupported-yearmonthintervaltype","errorCode":null,"errorMessage":"Unsupported YearMonthIntervalType.","messagePattern":"Unsupported YearMonthIntervalType\\.","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/FlinkTypeVisitor.java#L25-L61","documentation":"Flink's YearMonthIntervalType (INTERVAL YEAR/MONTH) has no mapping to an Iceberg type, so FlinkTypeVisitor deliberately throws UnsupportedOperationException when a type conversion visitor reaches it. Iceberg's schema model has no YEAR/MONTH interval type, so conversion of a table containing this column cannot proceed.","triggerScenarios":"Calling FlinkSchemaUtil.convert() or other FlinkTypeVisitor-based conversion (FlinkCatalog, sink/source schema resolution) on a row type containing a column declared as INTERVAL YEAR, INTERVAL YEAR TO MONTH, or INTERVAL MONTH.","commonSituations":"Defining a Flink Table API or SQL table with an interval-typed column (e.g. a date difference returning a YEAR/MONTH interval) then writing to Iceberg; introducing interval types via computed columns; assuming Iceberg supports interval types like it supports timestamps.","solutions":["Remove the YearMonthIntervalType column from the schema or cast it to a supported type (BIGINT month count or STRING) before writing to Iceberg.","Cast the interval to its numeric representation in SQL, e.g. CAST(interval_col AS BIGINT) or EXTRACT(MONTH ...).","Store start/end timestamps in Iceberg and derive the interval at query time instead.","If you own the FlinkTypeVisitor subclass, override visit(YearMonthIntervalType) with a custom mapping."],"exampleFix":"// before: table with interval column\nCREATE TABLE t (i INTERVAL YEAR TO MONTH, ...) WITH ('connector'='iceberg');\n// after: cast to a supported Iceberg type\nCREATE TABLE t (i BIGINT, ...) WITH ('connector'='iceberg');\nINSERT INTO t SELECT CAST(i AS BIGINT) FROM staged;","handlingStrategy":"validation","validationCode":"import org.apache.flink.table.types.logical.LogicalType;\nimport org.apache.flink.table.types.logical.YearMonthIntervalType;\n\nstatic void assertIcebergCompatible(org.apache.flink.table.api.Schema schema) {\n  schema.getColumns().forEach(c -> {\n    LogicalType t = c.getType().getLogicalType();\n    if (t instanceof YearMonthIntervalType) {\n      throw new IllegalArgumentException(\n          \"Column type \" + c + \" (INTERVAL YEAR/MONTH) is not supported by Iceberg; cast to BIGINT or STRING first.\");\n    }\n  });\n}","typeGuard":"static boolean isUnsupportedByIceberg(LogicalType t) {\n  return t instanceof YearMonthIntervalType || t instanceof DayTimeIntervalType;\n}","tryCatchPattern":null,"preventionTips":["Never declare INTERVAL YEAR/MONTH columns in tables feeding Iceberg sinks.","Cast computed intervals to BIGINT or STRING in the SELECT list before the sink.","Check the Iceberg-Flink type mapping table before designing schemas.","Add a schema check step that rejects unsupported logical types early."],"tags":["flink","iceberg","unsupported-type","type-conversion"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}