You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "firasbouzazi (via GitHub)" <gi...@apache.org> on 2026/10/03 22:48:09 UTC

[I] [common] Decimal#hashCode is inconsistent with Decimal#equals [fluss]

firasbouzazi opened a new issue, #4538:
URL: https://github.com/apache/fluss/issues/4538

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.
   
   
   ### Fluss version
   
   1.0.0 (latest release)
   
   ### Please describe the bug 🐞
   
   Decimal#equals compares values numerically via compareTo, so 1.0 and 1.00 are equal. But Decimal#hashCode returns toBigDecimal().hashCode(), and BigDecimal#hashCode depends on the scale, so equal values get different hash codes, which violates the hashCode contract.
   
   `Decimal a = Decimal.fromBigDecimal(new BigDecimal("1.0"), 5, 1);
   Decimal b = Decimal.fromBigDecimal(new BigDecimal("1.00"), 5, 2);
   a.equals(b);                                         // true
   a.hashCode() == b.hashCode();                        // false (311 vs 3102)
   new HashSet<>(Collections.singleton(a)).contains(b); // false`
   
   Decimal is @PublicStable, so users putting values in a HashSet/HashMap can silently miss equal values. Fix: hash toBigDecimal().stripTrailingZeros(). I'm willing to submit a PR.
   
   ### Solution
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
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: issues-unsubscribe@fluss.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [common] Decimal#hashCode is inconsistent with Decimal#equals [fluss]

Posted by "Anurag15v (via GitHub)" <gi...@apache.org>.
Anurag15v commented on issue #4538:
URL: https://github.com/apache/fluss/issues/4538#issuecomment-5980196606

   Hi @wuchong 
   Can you assign it to me ?
   


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [common] Decimal#hashCode is inconsistent with Decimal#equals [fluss]

Posted by "firasbouzazi (via GitHub)" <gi...@apache.org>.
firasbouzazi commented on issue #4538:
URL: https://github.com/apache/fluss/issues/4538#issuecomment-5985022939

   #4539 
   


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org