{"record":{"id":"8b6c81386b7b22ea","repo":"apache/iceberg","slug":"invalid-timestamp-type-unit-s","errorCode":null,"errorMessage":"Invalid Timestamp type unit: %s","messagePattern":"Invalid Timestamp type unit: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"orc/src/main/java/org/apache/iceberg/orc/OrcToIcebergVisitor.java","lineNumber":175,"sourceCode":"      case STRING:\n      case CHAR:\n      case VARCHAR:\n        builder.ofType(Types.StringType.get());\n        break;\n      case BINARY:\n        convertBinary(primitive, builder);\n        break;\n      case DATE:\n        builder.ofType(Types.DateType.get());\n        break;\n      case TIMESTAMP:\n        String unit = primitive.getAttributeValue(ORCSchemaUtil.TIMESTAMP_UNIT);\n        if (unit == null || ORCSchemaUtil.MICROS.equalsIgnoreCase(unit)) {\n          builder.ofType(Types.TimestampType.withoutZone());\n        } else if (unit.equalsIgnoreCase(ORCSchemaUtil.NANOS)) {\n          builder.ofType(Types.TimestampNanoType.withoutZone());\n        } else {\n          throw new IllegalStateException(String.format(\"Invalid Timestamp type unit: %s\", unit));\n        }\n\n        break;\n      case TIMESTAMP_INSTANT:\n        String tsUnit = primitive.getAttributeValue(ORCSchemaUtil.TIMESTAMP_UNIT);\n        if (tsUnit == null || ORCSchemaUtil.MICROS.equalsIgnoreCase(tsUnit)) {\n          builder.ofType(Types.TimestampType.withZone());\n        } else if (tsUnit.equalsIgnoreCase(ORCSchemaUtil.NANOS)) {\n          builder.ofType(Types.TimestampNanoType.withZone());\n        } else {\n          throw new IllegalStateException(String.format(\"Invalid Timestamp type unit: %s\", tsUnit));\n        }\n\n        break;\n      case DECIMAL:\n        builder.ofType(Types.DecimalType.of(primitive.getPrecision(), primitive.getScale()));\n        break;\n      default:","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/orc/OrcToIcebergVisitor.java#L157-L193","documentation":"When converting an ORC TIMESTAMP primitive (timestamp without zone) to an Iceberg type, OrcToIcebergVisitor reads the ORC-ICEBERG type attribute TIMESTAMP_UNIT. Only 'M'/'MICROS' (default when null) and 'N'/'NANOS' are valid; any other attribute value throws IllegalStateException. The attribute is set when Iceberg writes ORC files, so a bad value indicates corrupted or hand-edited metadata.","triggerScenarios":"Reading an ORC file whose TIMESTAMP column carries ORCSchemaUtil.TIMESTAMP_UNIT attribute value other than MICROS/NANOS (case-insensitive), during ORC→Iceberg schema conversion.","commonSituations":"Files written by other engines or older/custom Iceberg forks that wrote a different unit token; manually patched ORC metadata; corrupted custom attributes.","solutions":["Rewrite the ORC file with a supported unit attribute (MICROS or NANOS) — e.g. write through Iceberg so the attribute is set correctly.","Inspect the attribute with the ORC tooling and correct TIMESTAMP_UNIT to 'M' or 'N'.","Remove the bogus attribute entirely: a null unit defaults to MICROS and will convert cleanly.","Upgrade Iceberg if a version wrote a unit token that your reader version does not recognize."],"exampleFix":"// before (bad attribute)\nTIMESTAMP_UNIT = \"milliseconds\"\n// after\nTIMESTAMP_UNIT = \"N\" // NANOS, or remove attribute to default to MICROS","handlingStrategy":"validation","validationCode":"String unit = primitive.getAttributeValue(ORCSchemaUtil.TIMESTAMP_UNIT);\nif (unit != null && !ORCSchemaUtil.MICROS.equalsIgnoreCase(unit) && !ORCSchemaUtil.NANOS.equalsIgnoreCase(unit)) {\n  throw new IllegalArgumentException(\"Bad TIMESTAMP_UNIT: \" + unit);\n}","typeGuard":null,"tryCatchPattern":"try { schema = ORCSchemaUtil.convert(orcSchema); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"Invalid Timestamp type unit\")) { repairAttributeOrRewrite(file); } else throw e; }","preventionTips":["Never hand-edit ORC type attributes","Write ORC files through Iceberg so TIMESTAMP_UNIT is set canonically","Verify attributes of externally produced ORC files before registration","Keep writer and reader Iceberg versions aligned"],"tags":["orc","timestamp","type-attribute","schema-conversion"],"backgroundTag":"invalid-enum-value","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"}