PDGGK opened a new pull request, #9211:
URL: https://github.com/apache/paimon/pull/9211

   ### Purpose
   
   Closes #9210.
   
   `InternalRowUtils.equals` picked the `GenericMap` fast path by testing 
**data1**, then cast **data2** with no test of its own:
   
   ```java
   if (data1 instanceof GenericMap) {
       map1 = (GenericMap) data1;
       map2 = (GenericMap) data2;      // BinaryMap -> ClassCastException
   ```
   
   so `equals(generic, binary, mapType)` throws while `equals(binary, generic, 
mapType)` returns `true`.
   
   Two things say this is unintended rather than a restriction:
   
   - **The `else` branch exists because the representation varies.** One 
`MapType` is carried by `GenericMap`, `BinaryMap` or `ColumnarMap` 
interchangeably; the conversion is there to normalise exactly that. Gating it 
on data1's concrete class contradicts the branch it guards.
   - **`InternalRowUtils.hash` already treats them as interchangeable**, 
returning the same value for both. The class says "equal" by hash and throws 
when asked directly.
   
   Each operand is now converted on its own, keeping the fast path when both 
are already `GenericMap`.
   
   **Scope, deliberately narrow.** The other casts in this method — 
`(InternalRow) data2`, `(InternalArray) data2` — look like the same shape but 
are **interface** casts, and every representation implements those interfaces, 
so they cannot fail this way. Only the map branch casts to a concrete class. I 
have left them alone.
   
   ### Tests
   
   One case in `InternalRowUtilsTest` asserting three things:
   
   | assertion | before |
   |---|---|
   | `hash(generic) == hash(binary)` | green — this is what pins the intent |
   | `equals(binary, generic)` | green |
   | `equals(generic, binary)` | **ClassCastException** |
   
   Only the third changes. The other two being green both before and after is 
the point: they establish that the two representations were already meant to be 
equivalent, so the third is a defect rather than a new feature.
   
   ```
   InternalRowUtilsTest ... ClassCastException: class BinaryMap cannot be cast 
to class GenericMap
   Tests run: 7, Failures: 0, Errors: 1      <- master
   
   Tests run: 7, Failures: 0, Errors: 0      <- with the fix
   ```
   
   Related suites pass (`InternalRowSerializerTest`, 
`RowCompactedSerializerTest`). `spotless:check` and `checkstyle:check` exit 0.
   


-- 
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]

Reply via email to