Clustering / bulk_insert on a BINARY (bytes) sort column throws ClassCastException: [B cannot be cast to java.lang.Comparable
- Dominant language
- Java
- Stars
- 6.2k
- Forks
- 2.5k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 111
Description
When clustering (or `bulk_insert`) sorts by a column of BINARY/bytes type on the Spark record path (`HoodieSparkRecord`), the job fails with:
```
java.lang.ClassCastException: [B cannot be cast to java.lang.Comparable
at org.apache.hudi.common.util.collection.FlatLists.ofComparableArray(FlatLists.java:55)
```
`SortUtils.getComparableSortColumns` builds the sort key by reading each sort column's value and passing it to `FlatLists.ofComparableArray`, which casts every element to `Comparable`. On the Spark record path a binary column's value is a raw `byte[]`, which is not `Comparable`, so the cast throws and every clustering / bulk-insert attempt on that column fails.
The Avro record path does not hit this: `HoodieAvroUtils.getNestedFieldVal` returns a `java.nio.ByteBuffer` (which is `Comparable`) for the same column.
### Expected
A BINARY sort column should be usable as a clustering / bulk-insert sort key, ordered consistently with the Avro path.
### Environment
Hudi 1.x (master), Spark record type.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.