{"record":{"id":"dcf1519ce987b134","repo":"apache/iceberg","slug":"unsupported-unit-for-time-s","errorCode":null,"errorMessage":"Unsupported unit for time: %s","messagePattern":"Unsupported unit for time: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parquet/src/main/java/org/apache/iceberg/data/parquet/GenericParquetReaders.java","lineNumber":92,"sourceCode":"    return new GenericParquetReaders.DateReader(desc);\n  }\n\n  @Override\n  protected ParquetValueReader<?> timeReader(ColumnDescriptor desc) {\n    LogicalTypeAnnotation time = desc.getPrimitiveType().getLogicalTypeAnnotation();\n    Preconditions.checkArgument(\n        time instanceof LogicalTypeAnnotation.TimeLogicalTypeAnnotation,\n        \"Invalid time logical type: \" + time);\n\n    LogicalTypeAnnotation.TimeUnit unit =\n        ((LogicalTypeAnnotation.TimeLogicalTypeAnnotation) time).getUnit();\n    switch (unit) {\n      case MICROS:\n        return new GenericParquetReaders.TimeReader(desc);\n      case MILLIS:\n        return new GenericParquetReaders.TimeMillisReader(desc);\n      default:\n        throw new UnsupportedOperationException(\"Unsupported unit for time: \" + unit);\n    }\n  }\n\n  @Override\n  protected ParquetValueReader<?> timestampReader(ColumnDescriptor desc, boolean isAdjustedToUTC) {\n    if (desc.getPrimitiveType().getPrimitiveTypeName() == PrimitiveType.PrimitiveTypeName.INT96) {\n      return new GenericParquetReaders.TimestampInt96Reader(desc);\n    }\n\n    LogicalTypeAnnotation timestamp = desc.getPrimitiveType().getLogicalTypeAnnotation();\n    Preconditions.checkArgument(\n        timestamp instanceof LogicalTypeAnnotation.TimestampLogicalTypeAnnotation,\n        \"Invalid timestamp logical type: \" + timestamp);\n\n    LogicalTypeAnnotation.TimeUnit unit =\n        ((LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) timestamp).getUnit();\n    switch (unit) {\n      case NANOS:","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/data/parquet/GenericParquetReaders.java#L74-L110","documentation":"GenericParquetReaders.timeReader selects a reader for Parquet TIME logical types based on the time unit. Only MICROS and MILLIS are supported; other units (e.g. NANOS for time) throw UnsupportedOperationException because the generic readers have no corresponding conversion.","triggerScenarios":"Reading a Parquet file with a TIME logical type annotated with an unsupported unit (NANOS) through the generic Parquet reader path.","commonSituations":"Files written by tools that emit nanosecond time logical types (e.g. some Spark/other writers with NANOS time); reading non-Iceberg parquet files with generic readers.","solutions":["Rewrite the file with time stored in MICROS or MILLIS (or as the corresponding Iceberg time type).","Read with a reader implementation that supports the unit, or convert the column manually (read as long and scale).","If you control the writer, configure it to emit microsecond-precision time logical types."],"exampleFix":"// before: file has TIME(NANOS), generic reader throws\n// after: rewrite column to micros\n// df.withColumn(\"t\", col(\"t\").cast(\"timestamp\")).write.parquet(...) // or re-write as int64 micros","handlingStrategy":"validation","validationCode":"// Inspect time logical-type unit before reading\nTimeUnit unit = col.getTimeUnit();\nif (unit != TimeUnit.MICROSECONDS && unit != TimeUnit.MILLISECONDS) {\n  throw new IllegalStateException(\"Rewrite file: unsupported time unit \" + unit);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize writers on microsecond time logical types","Validate logical types of externally produced parquet before ingestion","Convert NANOS time columns during ETL, not at read time"],"tags":["parquet","logical-type","time"],"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"}