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

Sangkyoon Nam commented on FLINK-41106:
---------------------------------------

[~dianfu], I'd like to take this. At {{e206faa4ca2}} I reproduced both cases 
with an in-memory map state handler, the integer-key {{TypeError}} and 
{{put_all({'ab': 'wanted'})}} storing {{'a' -> 'b'}}, and the one-line fix to 
iterate {{dict_value.items()}} is ready. I'll add regression coverage for both 
cases in {{ProcessDataStreamTests}} in {{test_data_stream.py}}. Could you 
assign this to me?

> MapState.put_all() iterates dictionary keys instead of key-value pairs
> ----------------------------------------------------------------------
>
>                 Key: FLINK-41106
>                 URL: https://issues.apache.org/jira/browse/FLINK-41106
>             Project: Flink
>          Issue Type: Bug
>          Components: API / Python
>            Reporter: Dian Fu
>            Priority: Major
>
> MapState.put_all() accepts a dictionary, but its process-mode implementation 
> iterates the dictionary directly and attempts to unpack each key into a 
> key/value pair.
> Reproduction 1, using integer keys:
> {code:python}
> state.put_all({2: 200})
> {code}
> Expected:
> The state contains 2 -> 200.
> Actual:
> TypeError: cannot unpack non-iterable int object.
> Reproduction 2, using string keys and values:
> {code:python}
> state.put_all({'ab': 'wanted'})
> state.get('ab')  # None
> state.get('a')   # 'b'
> {code}
> Expected:
> The state contains 'ab' -> 'wanted', with no unintended 'a' entry.
> Actual:
> The key 'ab' is unpacked into 'a' and 'b'; the supplied value is ignored.
> Root cause:
> InternalSynchronousMapRuntimeState.put_all() uses "for map_key, map_value in 
> dict_value" instead of iterating dict_value.items().
> The affected implementation is in 
> flink-python/pyflink/fn_execution/state_impl.py.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to