{"record":{"id":"8a3754dd8c4995d3","repo":"apache/iceberg","slug":"unsupported-logical-type-8a3754","errorCode":null,"errorMessage":"Unsupported logical type: ","messagePattern":"Unsupported logical type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java","lineNumber":137,"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":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java#L119-L155","documentation":"SparkAvroWriter.primitive maps Avro logical types to Iceberg value writers. Only date, timestamp-millis/micros, decimal, and uuid logical types are recognized; anything else hits the default branch. This IllegalArgumentException reports that the Avro schema contains a logical type the Spark-to-Iceberg writer cannot handle.","triggerScenarios":"Writing Spark InternalRows to an Avro container whose schema declares a logical type other than date, timestamp-millis, timestamp-micros, decimal, or uuid (e.g. time-millis, time-micros, duration, or a custom logicalType).","commonSituations":"Third-party tools emit Avro schemas with time-millis/time-micros or vendor-specific logical types; attempts to write such data through Iceberg's SparkAvroWriter path fail.","solutions":["Remove or normalize the unsupported logical type from the Avro schema (write as underlying primitive).","Convert time-millis/time-micros fields to timestamp-micros or plain int/long before writing.","Upgrade Iceberg if a newer release supports the logical type.","If writing via a different library, use a writer that supports the logical type."],"exampleFix":"// before (Avro schema)\n{\"name\":\"t\",\"type\":\"int\",\"logicalType\":\"time-millis\"}\n// after\n{\"name\":\"t\",\"type\":\"long\",\"logicalType\":\"timestamp-micros\"}","handlingStrategy":"validation","validationCode":"// Inspect the Avro schema's logical types before writing\nfor (org.apache.avro.Schema.Field f : avroSchema.getFields()) {\n  org.apache.avro.LogicalType lt = f.schema().getLogicalType();\n  if (lt != null && !Set.of(\"date\", \"timestamp-millis\", \"timestamp-micros\", \"decimal\", \"uuid\").contains(lt.getName())) {\n    throw new IllegalStateException(\"Unsupported logical type: \" + lt.getName());\n  }\n}","typeGuard":"static boolean isSupportedLogicalType(org.apache.avro.Schema s) {\n  org.apache.avro.LogicalType lt = s.getLogicalType();\n  return lt == null || Set.of(\"date\", \"timestamp-millis\", \"timestamp-micros\", \"decimal\", \"uuid\").contains(lt.getName());\n}","tryCatchPattern":null,"preventionTips":["Normalize Avro schemas to supported logical types before writing","Check source tool output schemas for time-millis/time-micros","Prefer plain primitives when the logical type is unused"],"tags":["spark","avro","unsupported-type","logical-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"}