[BUG] Java `Scalar` does not consider Decimal scale for `.hashCode()`/`.equals()`
In its current implementation, the Scalar Java class does not consider the scale of a scalar value, when comparing two DECIMAL scalars.
Here is the section of Scalar.equals() that compares DECIMAL64 values:
case DECIMAL64:
return getLong() == other.getLong();
getLong() does not rescale the representative value of the scalar, based on a common scale. This implementation will equate two DECIMAL64 scalars of different scales, if their rep values are equal.
A similar argument could be made for Scalar.hashCode():
case DECIMAL64:
// ...
valueHash = Long.hashCode(getLong());
break;
AFAICT, the problem applies to DECIMAL32 and DECIMAL64, but not DECIMAL128. In adding support for DECIMAL128 in #11645, the comparisons are made using BigDecimal, rather than BigInteger.
Closing this as invalid; both hashCode() and equals() are correct.
-
Scalar.hashCode()returnsObjects.hashCode(type, valueHash).typeincludes the scale. -
Scalar.equals()comparestypefirst, before proceeding to compare values.type, again, includes the scale.
Apologies for the noise. This bug is invalid.
This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.
This would sill be good to fix