Dian Fu created FLINK-41106:
-------------------------------

             Summary: 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


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