{"record":{"id":"ac4cb8d56d9e91a9","repo":"apache/iceberg","slug":"invalid-bit-width-for-int-bitwidth","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/VariantReaderBuilder.java","lineNumber":261,"sourceCode":"                  PhysicalType.INT64, ParquetValueReaders.unboxed(desc));\n          break;\n        case 32:\n          reader =\n              ParquetVariantReaders.asVariant(\n                  PhysicalType.INT32, ParquetValueReaders.unboxed(desc));\n          break;\n        case 16:\n          reader =\n              ParquetVariantReaders.asVariant(\n                  PhysicalType.INT16, ParquetValueReaders.intsAsShort(desc));\n          break;\n        case 8:\n          reader =\n              ParquetVariantReaders.asVariant(\n                  PhysicalType.INT8, ParquetValueReaders.intsAsByte(desc));\n          break;\n        default:\n          throw new IllegalArgumentException(\"Invalid bit width for int: \" + logical.getBitWidth());\n      }\n\n      return Optional.of(reader);\n    }\n\n    @Override\n    public Optional<VariantValueReader> visit(UUIDLogicalTypeAnnotation logical) {\n      VariantValueReader reader =\n          ParquetVariantReaders.asVariant(PhysicalType.UUID, ParquetValueReaders.uuids(desc));\n      return Optional.of(reader);\n    }\n\n    private static PhysicalType variantDecimalType(PrimitiveType primitive) {\n      switch (primitive.getPrimitiveTypeName()) {\n        case FIXED_LEN_BYTE_ARRAY:\n        case BINARY:\n          return PhysicalType.DECIMAL16;\n        case INT64:","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/parquet/VariantReaderBuilder.java#L243-L279","documentation":"Thrown by VariantReaderBuilder's IntLogicalTypeAnnotation visitor when the signed INT logical annotation has a bit width other than 8, 16, 32, or 64. Valid Variant integer shredding widths are only those four; anything else is an invalid schema configuration.","triggerScenarios":"visit(IntLogicalTypeAnnotation) with a signed type whose getBitWidth() returns a value outside {8,16,32,64} (e.g. a malformed or hand-crafted logical annotation).","commonSituations":"Corrupt or hand-edited Parquet schemas; custom logical type annotations with unusual bit widths; a buggy third-party writer generating nonstandard INT logical types.","solutions":["Inspect the typed_value column schema and correct its INT logical annotation bit width to 8, 16, 32, or 64.","Rewrite the file with a standard writer so the logical type is normalized to a legal bit width.","Disable shredding for this Variant column so no typed integer column is read."],"exampleFix":"// before\n.as(LogicalTypeAnnotation.intType(12, true))\n\n// after\n.as(LogicalTypeAnnotation.intType(16, 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      && Set.of(8, 16, 32, 64).contains(i.getBitWidth());\n}","tryCatchPattern":"try {\n  buildReader(typedValueSchema);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Invalid bit width\")) normalizeSchemaAndRebuild();\n  else throw e;\n}","preventionTips":["Only construct IntLogicalTypeAnnotation with literal widths 8/16/32/64","Do not compute bit widths dynamically from external DDL without mapping to legal values","Round-trip schemas through a standard Parquet writer to normalize types"],"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"}