{"record":{"id":"4bca75889b364ac3","repo":"apache/iceberg","slug":"unsupported-unit-for-timestamp-s","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/GenericParquetReaders.java","lineNumber":123,"sourceCode":"        \"Invalid timestamp logical type: \" + timestamp);\n\n    LogicalTypeAnnotation.TimeUnit unit =\n        ((LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) timestamp).getUnit();\n    switch (unit) {\n      case NANOS:\n        return isAdjustedToUTC\n            ? new GenericParquetReaders.TimestamptzReader(desc, ChronoUnit.NANOS)\n            : new GenericParquetReaders.TimestampReader(desc, ChronoUnit.NANOS);\n      case MICROS:\n        return isAdjustedToUTC\n            ? new GenericParquetReaders.TimestamptzReader(desc, ChronoUnit.MICROS)\n            : new GenericParquetReaders.TimestampReader(desc, ChronoUnit.MICROS);\n      case MILLIS:\n        return isAdjustedToUTC\n            ? new GenericParquetReaders.TimestamptzMillisReader(desc)\n            : new GenericParquetReaders.TimestampMillisReader(desc);\n      default:\n        throw new UnsupportedOperationException(\"Unsupported unit for timestamp: \" + unit);\n    }\n  }\n\n  @Override\n  protected Object convertConstant(org.apache.iceberg.types.Type type, Object value) {\n    return GenericDataUtil.internalToGeneric(type, value);\n  }\n\n  private static final OffsetDateTime EPOCH = Instant.ofEpochSecond(0).atOffset(ZoneOffset.UTC);\n  private static final LocalDate EPOCH_DAY = EPOCH.toLocalDate();\n\n  private static class DateReader extends ParquetValueReaders.PrimitiveReader<LocalDate> {\n    DateReader(ColumnDescriptor desc) {\n      super(desc);\n    }\n\n    @Override\n    public LocalDate read(LocalDate reuse) {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/data/parquet/GenericParquetReaders.java#L105-L141","documentation":"GenericParquetReaders.timestampReader selects timestamp readers by logical-type unit. MICROS and MILLIS have dedicated readers; any other unit (NANOS) throws UnsupportedOperationException because the generic readers don't convert nanosecond timestamps.","triggerScenarios":"Reading a Parquet TIMESTAMP logical type with unit NANOS (adjusted-to-UTC or not) via GenericParquetReaders.","commonSituations":"Parquet files written by systems using nanosecond timestamps (e.g. pandas/pyarrow default, some legacy writers); mixing such files into Iceberg reads via the generic data readers.","solutions":["Rewrite the data with microsecond timestamps (Iceberg stores timestamps in micros).","Cast/convert nanosecond columns before reading: read as INT64 and divide by 1000, or use a custom reader.","Configure the upstream writer to emit TIMESTAMP_MICROS."],"exampleFix":"// before: pyarrow writes ns timestamps\n# table = pa.table({...}) ; pq.write_table(table, 'f.parquet')  # TIMESTAMP(NANOS)\n// after\n# table = table.set_column(i, 'ts', table['ts'].cast(pa.timestamp('us'))); pq.write_table(table, 'f.parquet')","handlingStrategy":"validation","validationCode":"// Verify timestamp unit before reading\nTimeUnit unit = col.getDateTimeUnit().getUnit();\nif (unit == TimeUnit.NANOSECONDS) {\n  throw new IllegalStateException(\"Rewrite to micros: unsupported timestamp unit NANOS\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure pyarrow/pandas writers to use TIMESTAMP_MICROS","Normalize timestamp precision in ingestion pipelines","Audit external parquet files' logical types before registration"],"tags":["parquet","logical-type","timestamp"],"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"}