refact: Refactor Literal operator== to delegate to CompareTo for consistent equality semantics#313
Conversation
…istent equality semantics
|
I found one issue that seems worth fixing before merging. After this change, That breaks the usual C++ hash contract: if Could we either keep equality representation-based, or update |
|
@zjw1111 I left a note on this point. In Paimon’s real usage, the column schema guarantees that the precision and scale of a decimal are fixed, so decimals with different scales will not be inserted into the same unordered_map. As a result, this hash/equality mismatch does not occur in practice. We will also revisit the design more carefully going forward. |
Purpose
No Linked issue.
The previous
Literal::operator==had an independent implementation that used epsilon-based comparison for FLOAT/DOUBLE and raw byte comparison for other types. This was inconsistent withCompareTo()which uses Java-compatible total ordering for floats (CompareFloatingPoint: NaN == NaN, -0.0 < +0.0) andDecimal::CompareTo()for decimals. Having two different equality semantics was confusing and error-prone.Now,
operator==usesCompareTo()which provides numeric equality (e.g. decimals with different scales can compare equal, floats use total ordering).Tests
API and Format
Documentation
Generative AI tooling