{"record":{"id":"73ce3dab77614df1","repo":"apache/iceberg","slug":"cannot-bucket-by-type","errorCode":null,"errorMessage":"Cannot bucket by type: ","messagePattern":"Cannot bucket by type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/transforms/Bucket.java","lineNumber":78,"sourceCode":"      case INTEGER:\n        return (B) new BucketInteger(numBuckets);\n      case TIME:\n      case TIMESTAMP:\n      case LONG:\n        return (B) new BucketLong(numBuckets);\n      case DECIMAL:\n        return (B) new BucketDecimal(numBuckets);\n      case STRING:\n        return (B) new BucketString(numBuckets);\n      case FIXED:\n      case BINARY:\n        return (B) new BucketByteBuffer(numBuckets);\n      case TIMESTAMP_NANO:\n        return (B) new BucketTimestampNano(numBuckets);\n      case UUID:\n        return (B) new BucketUUID(numBuckets);\n      default:\n        throw new IllegalArgumentException(\"Cannot bucket by type: \" + type);\n    }\n  }\n\n  private final int numBuckets;\n\n  private Bucket(int numBuckets) {\n    this.numBuckets = numBuckets;\n  }\n\n  public Integer numBuckets() {\n    return numBuckets;\n  }\n\n  @Override\n  public SerializableFunction<T, Integer> bind(Type type) {\n    Preconditions.checkArgument(canTransform(type), \"Cannot bucket by type: %s\", type);\n    return get(type, numBuckets);\n  }","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/transforms/Bucket.java#L60-L96","documentation":"Bucket.get(Type, int) only supports bucketing source types that Iceberg defines bucket transforms for (int, long, date, time, timestamp, timestamptz, string, uuid, decimal, ByteBuffer variants, timestamp nanos). Requesting a bucket function for any other type hits the default branch and throws IllegalArgumentException. This is a programming/spec error: the requested type is not bucketable.","triggerScenarios":"Calling Bucket.get(type, numBuckets) with an unsupported Type (e.g. boolean, map, list, struct), or binding a bucket transform to an incompatible type via Bucket.bind(type) when canTransform was bypassed.","commonSituations":"Constructing partition specs programmatically with a bucket transform on a non-bucketable column type; custom catalog/visitor code building transforms from parsed specs with wrong type mapping; version changes adding new bucketable types (e.g. TIMESTAMP_NANO) not handled by downstream code.","solutions":["Check Bucket.get(Type).contains(type) (or type(type).isBucketType()) before calling get/bind.","Fix the source column type to a bucketable type or choose a supported transform (truncate, identity) for that type.","If handling an unknown type is expected, catch IllegalArgumentException and surface a clear spec-validation error."],"exampleFix":"// before\nFunction<Integer, Integer> fn = Bucket.get(type, numBuckets).bind(type);\n// after\nPreconditions.checkArgument(Bucket.get(type).contains(type), \"Type %s is not bucketable\", type);\nFunction<Integer, Integer> fn = Bucket.get(type, numBuckets).bind(type);","handlingStrategy":"validation","validationCode":"if (!Bucket.get(type).contains(type)) { throw new IllegalArgumentException(\"Cannot bucket by type: \" + type); }","typeGuard":"boolean isBucketable(Type t) { return Bucket.get(t).contains(t); }","tryCatchPattern":"try { return Bucket.get(type, numBuckets).bind(type); } catch (IllegalArgumentException e) { throw new SchemaParseException(\"Unsupported bucket source type: \" + type, e); }","preventionTips":["Validate column types against Bucket.get(type) before building bucket transforms","Use TransformUtil/Transforms factory helpers that check canTransform","Keep spec parsing tests covering every bucketable type"],"tags":["java","transforms","partitioning","invalid-argument"],"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-14T11:17:12.474Z"}