Phixsura commented on issue #24107:
URL:
https://github.com/apache/shardingsphere/issues/24107#issuecomment-4471492330
PR #38699.
Root cause: in `OrderByValue.getOrderValues`, the precondition `value
instanceof Comparable` throws `NotImplementComparableValueException` when the
value is a `byte[]`, because Java arrays do not implement `Comparable`. MySQL
VARBINARY/BINARY columns surface as `byte[]` through JDBC, so any `ORDER BY`
over such a column fails in the sharding merge layer even though native MySQL
accepts the same query.
Fix wraps `byte[]` values in a small `ComparableByteArray` adapter that
orders unsigned-lexicographically (matching MySQL's binary collation). Other
types still flow through the existing precondition.
Tests: 5 cases on the new adapter (equal, single-byte diff, unsigned high
byte, shorter-prefix-is-less, empty arrays) and an additional `OrderByValue`
ASC scenario where `{1, 2}` sorts before `{0x80}` to confirm the unsigned
ordering reaches the merge comparison.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]