{"record":{"id":"144ce9c1e4b98076","repo":"apache/iceberg","slug":"unsupported-logical-type-logicaltype-144ce9","errorCode":null,"errorMessage":"Unsupported logical type: ${logicalType}","messagePattern":"Unsupported logical type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/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.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java#L124-L160","documentation":"SparkAvroWriter.primitive builds Avro value writers for a Spark primitive type; within a STRING branch it handles known logical types (decimal, uuid) and throws IllegalArgumentException for any other Avro logical type annotation it doesn't recognize.","triggerScenarios":"Writing Spark data to Iceberg Avro files when an Avro string primitive carries a logicalType name not in the supported set (only decimal and uuid are handled).","commonSituations":"Avro schemas with custom/less-common logical types (e.g. time-micros annotations on unexpected types) feeding the writer path; schema from a newer spec writer.","solutions":["Upgrade the Iceberg runtime so the writer recognizes the logical type.","Adjust the Avro schema to drop the unsupported logical type annotation if the underlying primitive is what you intend.","Convert the data to a supported type before writing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify Avro schema logical types are only decimal or uuid before writing\nif (!Set.of(\"decimal\", \"uuid\").contains(logicalTypeName)) throw new IllegalArgumentException(\"unsupported\");","typeGuard":"if (\"string\".equals(primitive.getType().getName()) && logicalType != null && !\"decimal\".equals(logicalType.getName()) && !\"uuid\".equals(logicalType.getName())) { /* unsupported */ }","tryCatchPattern":"try { write(dataset); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported logical type\")) { /* fix schema */ } else throw e; }","preventionTips":["Restrict Avro schema logical types to decimal and uuid","Validate source Avro schemas before configuring writes","Upgrade runtime for newer logical type support"],"tags":["spark","avro","writer","unsupported-type"],"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"}