{"record":{"id":"c3c7393229b45a52","repo":"apache/iceberg","slug":"unsupported-logical-type-c3c739","errorCode":null,"errorMessage":"Unsupported logical type: ","messagePattern":"Unsupported logical type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/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.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java#L124-L160","documentation":"SparkAvroWriter.primitive maps Spark types to Avro value writers. For a BYTES primitive with a logical type it recognizes decimal and uuid only; any other Avro logical type name hits the default branch and throws IllegalArgumentException('Unsupported logical type: ...').","triggerScenarios":"Writing Spark data through SparkAvroWriter when the Avro schema declares a BYTES/FIXED primitive with a logical type the writer doesn't support (anything besides decimal and uuid).","commonSituations":"Custom or vendor-specific Avro logical types in the schema; newer logical types written by other tools being read/written by an older Iceberg runtime; schema evolution introducing logical types the writer predates.","solutions":["Upgrade the Iceberg runtime to a version supporting the logical type","Remove or change the unsupported logical type in the Avro schema (e.g. use plain bytes)","Convert the data to a supported type before writing (e.g. UUID strings, decimal)","If the type should be supported, file an issue with the logical type name"],"exampleFix":"// before\nSchema.Field f = new Schema.Field(\"id\", LogicalTypes.unknown().addToSchema(Schema.create(Schema.Type.BYTES)));\n// after: use a supported logical type or plain bytes\nSchema.Field f = new Schema.Field(\"id\", Schema.create(Schema.Type.BYTES));","handlingStrategy":"validation","validationCode":"for (Schema.Field f : avroSchema.getFields()) {\n  LogicalType lt = f.schema().getLogicalType();\n  if (lt != null && !\"decimal\".equals(lt.getName()) && !\"uuid\".equals(lt.getName())) {\n    throw new IllegalArgumentException(\"Unsupported logical type: \" + lt);\n  }\n}","typeGuard":"boolean supported(Schema s) { LogicalType lt = s.getLogicalType(); return lt == null || lt instanceof LogicalTypes.Decimal || \"uuid\".equals(lt.getName()); }","tryCatchPattern":"try { writer.write(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported logical type\")) { /* fix schema */ } else { throw e; } }","preventionTips":["Restrict Avro schemas to decimal and uuid logical types","Validate Avro schemas against the supported set before writing","Keep the Iceberg runtime current for new logical types"],"tags":["spark","avro","writer","logical-type","unsupported"],"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"}