{"record":{"id":"65bbcd2cdde6b767","repo":"apache/iceberg","slug":"invalid-bit-width-for-int-bitwidth-65bbcd","errorCode":null,"errorMessage":"Invalid bit width for int: ${bitWidth}","messagePattern":"Invalid bit width for int: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"parquet/src/main/java/org/apache/iceberg/parquet/VariantWriterBuilder.java","lineNumber":282,"sourceCode":"          writer =\n              ParquetVariantWriters.primitive(\n                  ParquetValueWriters.tinyints(desc), PhysicalType.INT8);\n          return Optional.of(writer);\n        case 16:\n          writer =\n              ParquetVariantWriters.primitive(ParquetValueWriters.shorts(desc), PhysicalType.INT16);\n          return Optional.of(writer);\n        case 32:\n          writer =\n              ParquetVariantWriters.primitive(ParquetValueWriters.ints(desc), PhysicalType.INT32);\n          return Optional.of(writer);\n        case 64:\n          writer =\n              ParquetVariantWriters.primitive(ParquetValueWriters.longs(desc), PhysicalType.INT64);\n          return Optional.of(writer);\n      }\n\n      throw new IllegalArgumentException(\"Invalid bit width for int: \" + logical.getBitWidth());\n    }\n\n    @Override\n    public Optional<ParquetValueWriter<?>> visit(UUIDLogicalTypeAnnotation uuidLogicalType) {\n      ParquetValueWriter<VariantValue> writer =\n          ParquetVariantWriters.primitive(ParquetValueWriters.uuids(desc), PhysicalType.UUID);\n      return Optional.of(writer);\n    }\n  }\n}\n","sourceCodeStart":264,"sourceCodeEnd":293,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/parquet/VariantWriterBuilder.java#L264-L293","documentation":"Thrown by VariantWriterBuilder's IntLogicalTypeAnnotation visitor when the signed INT logical type's bit width is not 8, 16, 32, or 64. Only those four widths have corresponding Variant writers (INT8/16/32/64 physical types); any other width is an invalid schema.","triggerScenarios":"visit(IntLogicalTypeAnnotation) with logical.getBitWidth() outside {8,16,32,64} while building a shredded Variant writer.","commonSituations":"Hand-crafted or corrupted schemas with nonstandard INT bit widths; buggy schema-generation code computing bit widths dynamically; translating DDL with unusual integer sizes directly into Parquet logical types.","solutions":["Snap the typed_value integer logical type to one of 8, 16, 32, or 64 bits (signed).","Fix the schema-generation code to map source types onto the four legal widths (e.g. round small ints up to 8 or 16).","Disable shredding for the column if its type cannot be represented with a legal bit width."],"exampleFix":"// before\n.as(LogicalTypeAnnotation.intType(24, true))\n\n// after\n.as(LogicalTypeAnnotation.intType(32, true))","handlingStrategy":"validation","validationCode":"int w = logical.getBitWidth();\nPreconditions.checkArgument(w == 8 || w == 16 || w == 32 || w == 64,\n    \"INT bit width must be 8/16/32/64, got %s\", w);","typeGuard":"boolean hasLegalIntWidth(LogicalTypeAnnotation l) {\n  return l instanceof IntLogicalTypeAnnotation i\n      && (i.getBitWidth() == 8 || i.getBitWidth() == 16 || i.getBitWidth() == 32 || i.getBitWidth() == 64);\n}","tryCatchPattern":"try {\n  buildVariantWriter(schema);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Invalid bit width\")) snapToLegalWidthAndRebuild();\n  else throw e;\n}","preventionTips":["Map source integer widths onto 8/16/32/64 when generating shredding schemas","Never emit logical annotations with arbitrary bit widths","Add schema assertions in writer tests for all shredded columns"],"tags":["parquet","variant","shredding","bit-width"],"backgroundTag":"invalid-argument-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}