{"record":{"id":"b627e1f04e0c2e0c","repo":"apache/iceberg","slug":"unsupported-distincttype","errorCode":null,"errorMessage":"Unsupported DistinctType.","messagePattern":"Unsupported DistinctType\\.","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":53,"sourceCode":"\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\n  public T visit(NullType nullType) {\n    throw new UnsupportedOperationException(\"Unsupported NullType.\");\n  }\n\n  @Override\n  public T visit(RawType<?> rawType) {\n    throw new UnsupportedOperationException(\"Unsupported RawType.\");\n  }\n\n  @Override","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/FlinkTypeVisitor.java#L35-L71","documentation":"Flink DistinctType is a user-defined distinct logical type with no Iceberg counterpart, so FlinkTypeVisitor throws UnsupportedOperationException when a conversion visitor encounters it. Iceberg schemas cannot represent this type, so conversion is rejected.","triggerScenarios":"Converting a row type containing a column whose logical type is a Flink DistinctType, e.g. created via DataTypes.DISTINCT(...) or registered distinct UDTs, during schema conversion for an Iceberg sink or catalog operation.","commonSituations":"Using DataTypes.DISTINCT in Table API columns feeding an Iceberg sink; connector/UDF outputs that emit distinct-typed columns; schemas copied from codebases using Flink's advanced type system.","solutions":["Replace the DistinctType column with its underlying base type (e.g. DataTypes.INT or STRING).","Cast the column to its underlying type in SQL, e.g. CAST(distinct_col AS INT), before the Iceberg sink.","Avoid DataTypes.DISTINCT in table definitions written to Iceberg; use a plain type plus application-level validation.","Override visit(DistinctType) in a custom FlinkTypeVisitor subclass to map it to the underlying Iceberg type."],"exampleFix":"// before\nDataTypes.DISTINCT(\"userId\", DataTypes.BIGINT())\n// after\nDataTypes.BIGINT() // plain type; enforce semantics in application code","handlingStrategy":"validation","validationCode":"import org.apache.flink.table.types.logical.DistinctType;\nimport org.apache.flink.table.types.logical.LogicalType;\n\nstatic boolean containsDistinctType(org.apache.flink.table.api.Schema schema) {\n  return schema.getColumns().stream()\n      .anyMatch(c -> c.getType().getLogicalType() instanceof DistinctType);\n}","typeGuard":"static boolean isDistinctType(LogicalType t) {\n  return t instanceof DistinctType;\n}","tryCatchPattern":null,"preventionTips":["Do not use DataTypes.DISTINCT in table definitions written to Iceberg.","Use the underlying base type plus application-level invariants instead of distinct types.","Cast distinct-typed columns to their base type before the sink.","Document type restrictions for shared Table API schemas."],"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"}