{"record":{"id":"e8f0fd0063729431","repo":"apache/iceberg","slug":"unsupported-unit-for-timestamp-s-e8f0fd","errorCode":null,"errorMessage":"Unsupported unit for timestamp: %s","messagePattern":"Unsupported unit for timestamp: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parquet/src/main/java/org/apache/iceberg/data/parquet/GenericParquetWriter.java","lineNumber":168,"sourceCode":"    @Override\n    public void write(int repetitionLevel, byte[] value) {\n      Preconditions.checkArgument(\n          value.length == length,\n          \"Cannot write byte buffer of length %s as fixed[%s]\",\n          value.length,\n          length);\n      column.writeBinary(repetitionLevel, Binary.fromReusedByteArray(value));\n    }\n  }\n\n  private static ChronoUnit fromParquet(LogicalTypeAnnotation.TimeUnit unit) {\n    switch (unit) {\n      case MICROS:\n        return ChronoUnit.MICROS;\n      case NANOS:\n        return ChronoUnit.NANOS;\n      default:\n        throw new UnsupportedOperationException(\"Unsupported unit for timestamp: \" + unit);\n    }\n  }\n}\n","sourceCodeStart":150,"sourceCodeEnd":172,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/data/parquet/GenericParquetWriter.java#L150-L172","documentation":"GenericParquetWriter.fromParquet maps a Parquet timestamp unit to a ChronoUnit for writer construction; only MICROS and NANOS map. Other units (e.g. MILLIS) throw UnsupportedOperationException since the writer has no conversion for them.","triggerScenarios":"Writing a Parquet TIMESTAMP logical type with unit MILLIS (or anything other than MICROS/NANOS) through GenericParquetWriter.timestampWriter -> fromParquet.","commonSituations":"Interoperating with external files/writers that define MILLIS timestamp logical types and using the generic writer to produce matching schemas; hand-built Parquet schemas with unusual units.","solutions":["Write timestamps in MICROS (Iceberg's canonical representation) — adjust the requested Parquet schema.","Convert the source values to micros/nanos before writing.","Use a writer path that supports the unit you need."],"exampleFix":"// before: requesting millis timestamp write\n// Types.TimestampType -> parquet TIMESTAMP(MILLIS) -> throws\n// after: use micros\nTypes.TimestampType.withZone(); // writes TIMESTAMP(MICROS)","handlingStrategy":"validation","validationCode":"// Confirm the target parquet timestamp unit is MICROS or NANOS before writing\nif (targetUnit != TimeUnit.MICROSECONDS && targetUnit != TimeUnit.NANOSECONDS) {\n  throw new IllegalArgumentException(\"Write timestamps as MICROS (or NANOS), not \" + targetUnit);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use Iceberg's canonical micros timestamp representation","Don't hand-craft parquet schemas with millis timestamp units","Test cross-engine writes for timestamp unit compatibility"],"tags":["parquet","logical-type","timestamp","write-path"],"backgroundTag":"unsupported-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"}