{"record":{"id":"d40e3b3e57f70a16","repo":"apache/iceberg","slug":"unsupported-logical-type-logicaltype-d40e3b","errorCode":null,"errorMessage":"Unsupported logical type: {logicalType}","messagePattern":"Unsupported logical type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java","lineNumber":142,"sourceCode":"      if (logicalType != null) {\n        switch (logicalType.getName()) {\n          case \"date\":\n            // Spark uses the same representation\n            return ValueWriters.ints();\n\n          case \"timestamp-micros\":\n            // Spark uses the same representation\n            return ValueWriters.longs();\n\n          case \"decimal\":\n            LogicalTypes.Decimal decimal = (LogicalTypes.Decimal) logicalType;\n            return SparkValueWriters.decimal(decimal.getPrecision(), decimal.getScale());\n\n          case \"uuid\":\n            return SparkValueWriters.uuids();\n\n          default:\n            throw new IllegalArgumentException(\"Unsupported logical type: \" + logicalType);\n        }\n      }\n\n      switch (primitive.getType()) {\n        case NULL:\n          return ValueWriters.nulls();\n        case BOOLEAN:\n          return ValueWriters.booleans();\n        case INT:\n          if (type instanceof ByteType) {\n            return ValueWriters.tinyints();\n          } else if (type instanceof ShortType) {\n            return ValueWriters.shorts();\n          }\n          return ValueWriters.ints();\n        case LONG:\n          return ValueWriters.longs();\n        case FLOAT:","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java#L124-L160","documentation":"SparkAvroWriter maps Avro schema primitives to Iceberg value writers for writing Avro data. Within a logical type (string logical types like date/time/decimal/uuid), an unrecognized logical type name has no writer mapping, so it throws IllegalArgumentException. This keeps the writer from silently producing wrong encodings for unknown Avro logical types.","triggerScenarios":"Writing Avro records whose schema declares a string logical type other than date, time-millis, time-micros, timestamp-millis, timestamp-micros, local-timestamp-*, decimal, or uuid — e.g. a custom or vendor-specific Avro logical type.","commonSituations":"Reading Avro files produced by third-party tools with custom logical types; newer Avro logical types not yet mapped; schema evolution introducing unknown logical types.","solutions":["Remove or remap the unsupported logical type in the Avro schema (use a plain primitive type)","Upgrade Iceberg in case a newer version maps the logical type","Pre-convert the data to a supported type before writing","Register/log an issue to add support for the specific logical type"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"org.apache.avro.Schema field = avroSchema.getField(\"f\").schema();\nif (field.getLogicalType() != null && field.getLogicalType().getName().equals(\"my-custom-type\")) {\n  throw new IllegalStateException(\"Unsupported Avro logical type: my-custom-type\");\n}","typeGuard":"boolean supportedLogicalType(org.apache.avro.Schema s) {\n  LogicalType lt = s.getLogicalType();\n  return lt == null || Set.of(\"date\",\"time-millis\",\"time-micros\",\"timestamp-millis\",\n      \"timestamp-micros\",\"local-timestamp-millis\",\"local-timestamp-micros\",\n      \"decimal\",\"uuid\").contains(lt.getName());\n}","tryCatchPattern":"try {\n  writer.write(row);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported logical type\")) { /* normalize the schema */ }\n  else throw e;\n}","preventionTips":["Restrict Avro schemas to standard logical types","Normalize third-party schemas before Iceberg Avro writes","Keep Iceberg up to date for new logical type mappings"],"tags":["spark","avro","writer","logical-types"],"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"}