{"record":{"id":"42146d1f4b5af78f","repo":"apache/iceberg","slug":"unknown-logical-type-42146d","errorCode":null,"errorMessage":"Unknown logical type: ","messagePattern":"Unknown logical type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkPlannedAvroReader.java","lineNumber":162,"sourceCode":"          case \"timestamp-millis\":\n            // adjust to microseconds\n            ValueReader<Long> longs = ValueReaders.longs();\n            return (ValueReader<Long>) (decoder, ignored) -> longs.read(decoder, null) * 1000L;\n\n          case \"timestamp-micros\":\n            // Spark uses the same representation\n            return ValueReaders.longs();\n\n          case \"decimal\":\n            return SparkValueReaders.decimal(\n                ValueReaders.decimalBytesReader(primitive),\n                ((LogicalTypes.Decimal) logicalType).getScale());\n\n          case \"uuid\":\n            return SparkValueReaders.uuids();\n\n          default:\n            throw new IllegalArgumentException(\"Unknown logical type: \" + logicalType);\n        }\n      }\n\n      switch (primitive.getType()) {\n        case NULL:\n          return ValueReaders.nulls();\n        case BOOLEAN:\n          return ValueReaders.booleans();\n        case INT:\n          if (partner != null && partner.typeId() == Type.TypeID.LONG) {\n            return ValueReaders.intsAsLongs();\n          }\n          return ValueReaders.ints();\n        case LONG:\n          return ValueReaders.longs();\n        case FLOAT:\n          if (partner != null && partner.typeId() == Type.TypeID.DOUBLE) {\n            return ValueReaders.floatsAsDoubles();","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkPlannedAvroReader.java#L144-L180","documentation":"SparkPlannedAvroReader.primitive() maps Avro logical types (LogicalType) to Spark value readers. When an Avro schema carries a logical type name that is not one of the supported ones (e.g. not decimal or uuid in this branch), it throws IllegalArgumentException(\"Unknown logical type: ...\"). Reading files containing such a schema fails at reader construction.","triggerScenarios":"Reading an Avro-backed Iceberg data file whose field schema declares a logical type other than the handled names (e.g. 'time-micros', 'timestamp-millis', or custom logical types) while planning a Spark scan.","commonSituations":"Avro files produced by other systems (Kafka Connect, custom pipelines) with logical annotations Iceberg's Avro reader does not map; schema registry injecting logical types; version skew between producer and reader Iceberg versions.","solutions":["Inspect the Avro schema (printSchema / avro tools) to see which logical type is declared","Rewrite the data removing the unsupported logical annotation (treat the field as its underlying primitive)","Cast or re-map the column in the Iceberg table schema to a supported type","Upgrade Iceberg if the logical type is supported in newer releases"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Schema avroSchema = datumReader.getSchema();\nfor (Field f : avroSchema.getFields()) {\n  LogicalType lt = f.schema().getLogicalType();\n  if (lt != null && !Set.of(\"decimal\", \"uuid\").contains(lt.getName())) {\n    throw new IllegalStateException(\"Unsupported Avro logical type in field \" + f.name() + \": \" + lt);\n  }\n}","typeGuard":"boolean hasSupportedLogicalType(Schema s) {\n  LogicalType lt = s.getLogicalType();\n  return lt == null || \"decimal\".equals(lt.getName()) || \"uuid\".equals(lt.getName());\n}","tryCatchPattern":"try {\n  spark.read().format(\"iceberg\").load(\"db.tbl\");\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown logical type\")) {\n    // strip or rewrite the unsupported logical annotation, then retry\n  } else {\n    throw e;\n  }\n}","preventionTips":["Inspect Avro schemas from external producers (Kafka Connect, registries) before ingesting into Iceberg tables","Strip unsupported logical annotations and treat fields as their underlying primitive types","Keep the Iceberg version of the reader at least as new as the writer's logical-type usage"],"tags":["avro","spark","logical-type","reader"],"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-14T16:17:12.679Z"}