{"record":{"id":"f5a59bdc0426569d","repo":"apache/iceberg","slug":"avro-writer-does-not-support-variant-types","errorCode":null,"errorMessage":"Avro writer does not support variant types","messagePattern":"Avro writer does not support variant types","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvroWriter.java","lineNumber":108,"sourceCode":"\n      int repeatedD = type.getMaxDefinitionLevel(repeatedPath);\n      int repeatedR = type.getMaxRepetitionLevel(repeatedPath);\n\n      Type keyType = repeatedKeyValue.getType(0);\n      int keyD = type.getMaxDefinitionLevel(path(keyType.getName()));\n      Type valueType = repeatedKeyValue.getType(1);\n      int valueD = type.getMaxDefinitionLevel(path(valueType.getName()));\n\n      return ParquetValueWriters.maps(\n          repeatedD,\n          repeatedR,\n          ParquetValueWriters.option(keyType, keyD, keyWriter),\n          ParquetValueWriters.option(valueType, valueD, valueWriter));\n    }\n\n    @Override\n    public ParquetValueWriter<?> variant(GroupType variant) {\n      throw new UnsupportedOperationException(\"Avro writer does not support variant types\");\n    }\n\n    @Override\n    public ParquetValueWriter<?> primitive(PrimitiveType primitive) {\n      ColumnDescriptor desc = type.getColumnDescription(currentPath());\n\n      if (primitive.getOriginalType() != null) {\n        switch (primitive.getOriginalType()) {\n          case ENUM:\n          case JSON:\n          case UTF8:\n            return ParquetValueWriters.strings(desc);\n          case DATE:\n          case INT_8:\n          case INT_16:\n          case INT_32:\n            return ParquetValueWriters.ints(desc);\n          case INT_64:","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvroWriter.java#L90-L126","documentation":"ParquetAvroWriter converts Parquet schemas into ParquetValueWriters for writing Avro data to Parquet files. Variant types (Parquet's semi-structured Variant logical type) have no Avro representation in this writer, so the library deliberately rejects them at write-planning time rather than silently corrupting data.","triggerScenarios":"Writing a Parquet schema that contains a Variant group type via the Avro-backed Parquet writer (ParquetAvro.buildWriter); the variant() visitor method is invoked during schema conversion.","commonSituations":"A table gains a variant column (Iceberg v3 feature) while the pipeline still writes with the Avro writer path; users assume Avro support parity with the generic/Spark writers.","solutions":["Remove the variant column from the data being written or write it as a supported type (e.g., string/JSON bytes)","Use a different Parquet writer that supports variants (e.g., the Iceberg internal/GenericParquetWriter path)","Pin/downgrade the table schema so variant columns are not present, or use format-version 2 tables without variant fields"],"exampleFix":"// before: schema contains Variant type 'v'\nParquetAvroWriter<?> writer = ParquetAvro.write(fileSchema).build();\n// after: exclude or convert variant before writing\nSchema withoutVariant = new Schema(schema.columns().stream()\n    .filter(c -> !c.transform().equals(Types.VariantType.get()))\n    .collect(Collectors.toList()));","handlingStrategy":"validation","validationCode":"boolean hasVariant = schema.columns().stream().anyMatch(c -> c.type().typeId() == Type.TypeID.VARIANT);\nif (hasVariant) throw new IllegalArgumentException(\"Variant columns unsupported for Avro Parquet writes\");","typeGuard":"static boolean isVariantType(Type t) { return t != null && t.typeId() == Type.TypeID.VARIANT; }","tryCatchPattern":null,"preventionTips":["Check column type IDs before selecting the Avro writer path","Keep variant columns out of tables written via Avro integration","Track Iceberg release notes for variant writer support"],"tags":["parquet","avro","variant","unsupported-type"],"backgroundTag":"unsupported-operation","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"}