[ 
https://issues.apache.org/jira/browse/FLINK-40986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18126925#comment-18126925
 ] 

Dian Fu edited comment on FLINK-40986 at 10/14/26 5:23 AM:
-----------------------------------------------------------

Merged to 
- master via aced6782c114b0b9deab309e17765335459bd77a
- release-2.3 via 43450c9edd6ac5f3c5c3732a2a208ee55a5f2580
- release-1.20 via 075e70ad9dc6df4f7a275231b1d5d249fa1adf92


was (Author: dianfu):
Merged to master via aced6782c114b0b9deab309e17765335459bd77a

> Equal named Rows can have different hash values in PyFlink
> ----------------------------------------------------------
>
>                 Key: FLINK-40986
>                 URL: https://issues.apache.org/jira/browse/FLINK-40986
>             Project: Flink
>          Issue Type: Bug
>          Components: API / Python
>            Reporter: Biao Geng
>            Assignee: Biao Geng
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 2.4.0
>
>
> h3. Problem
> Named PyFlink {{Row}} instances compare equal when their field names and 
> corresponding values match, regardless of field order. However, 
> {{Row._{_}hash{_}_}} hashes values in their original storage order. 
> Consequently, equal rows can have different hashes, violating Python's 
> equality/hash contract.
> This causes incorrect deduplication in Python sets and failed lookups or 
> duplicate entries in Python dictionaries when equal named rows have different 
> field orders.
> h3. Reproduce
> {code:python}
> from pyflink.common import Row
> left = Row(a=1, b=2)
> right = Row(b=2, a=1)
> print(left == right)
> print(hash(left) == hash(right))
> print(len({left, right}))
> print({left: "value"}.get(right, "NOT FOUND"))
> {code}
> Actual output:
> {code:java}
> True
> False
> 2
> NOT FOUND
> {code}
> Expected output:
> {code:java}
> True
> True
> 1
> value
> {code}
> h3. Root cause
> In {{{}flink-python/pyflink/common/types.py{}}}, {{Row._{_}eq{_}}} 
> \{_}compares named-row values in sorted field-name order, while 
> {{Row.}}{_}{{{}{_}hash{_}_{}}} hashes {{tuple(self)}} in the original value 
> order.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to