{"record":{"id":"069f3f96c7c48f64","repo":"apache/iceberg","slug":"invalid-iceberg-type-s-corresponding-to-flink-log-069f3f","errorCode":null,"errorMessage":"Invalid iceberg type %s corresponding to Flink logical type %s","messagePattern":"Invalid iceberg type (.+?) corresponding to Flink logical type (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/FlinkOrcWriter.java","lineNumber":165,"sourceCode":"          }\n        case TIMESTAMP_NANO:\n          Types.TimestampNanoType timestampNanoType = (Types.TimestampNanoType) iPrimitive;\n          if (timestampNanoType.shouldAdjustToUTC()) {\n            return FlinkOrcWriters.timestampNanoTzs();\n          } else {\n            return FlinkOrcWriters.timestampNanos();\n          }\n        case STRING:\n          return FlinkOrcWriters.strings();\n        case UUID:\n        case FIXED:\n        case BINARY:\n          return GenericOrcWriters.byteArrays();\n        case DECIMAL:\n          Types.DecimalType decimalType = (Types.DecimalType) iPrimitive;\n          return FlinkOrcWriters.decimals(decimalType.precision(), decimalType.scale());\n        default:\n          throw new IllegalArgumentException(\n              String.format(\n                  \"Invalid iceberg type %s corresponding to Flink logical type %s\",\n                  iPrimitive, flinkPrimitive));\n      }\n    }\n  }\n}\n","sourceCodeStart":147,"sourceCodeEnd":173,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/FlinkOrcWriter.java#L147-L173","documentation":"FlinkOrcWriter.primitive() throws IllegalArgumentException 'Invalid iceberg type <type> corresponding to Flink logical type <type>' when an Iceberg primitive type cannot be mapped to an ORC writer for the given Flink logical type — the Iceberg type and Flink type pair is unsupported (mismatch between declared schema and Flink RowType).","triggerScenarios":"Writing ORC files where a column's Iceberg primitive and Flink LogicalType don't form a supported pair (e.g. Iceberg BINARY paired with an unexpected Flink type, or a primitive combination with no branch in the switch).","commonSituations":"Custom FlinkRowType construction not derived from the Iceberg schema; writer framework upgrades changing type mappings; writing tables whose schema was transformed incorrectly.","solutions":["Ensure the Flink RowType is built from the Iceberg schema via FlinkSchemaUtil.convert(schema).","Remove/retype columns producing unsupported pairs (check both types in the message).","Use a different write format (Parquet/Avro) if the mapping exists there.","Upgrade iceberg-flink if a newer version supports the pairing."],"exampleFix":"// before\nRowType rowType = customRowType(); // not matching table schema\n// after\nRowType rowType = FlinkSchemaUtil.convert(table.schema());","handlingStrategy":"validation","validationCode":"RowType rowType = FlinkSchemaUtil.convert(table.schema()); // derive Flink type from Iceberg schema, never hand-build","typeGuard":null,"tryCatchPattern":"try {\n  writer.write(rowData);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Invalid iceberg type\")) {\n    LOG.error(\"Flink/Iceberg type pair unsupported: {}\", e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Always derive Flink RowType via FlinkSchemaUtil.convert(schema).","Check the supported Iceberg<->Flink type mapping table before using unusual types.","Test writes on a sample table with the same schema before production."],"tags":["flink","orc","writer","type-mismatch"],"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-14T16:17:12.679Z"}