You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Shahin Azad (JIRA)" <ji...@apache.org> on 2016/06/19 08:49:05 UTC

[jira] [Created] (FLINK-4092) Stringify map function's type conversion problem is breaking running provided example in documents

Shahin Azad created FLINK-4092:
----------------------------------

             Summary: Stringify map function's type conversion problem is breaking running provided example in documents
                 Key: FLINK-4092
                 URL: https://issues.apache.org/jira/browse/FLINK-4092
             Project: Flink
          Issue Type: Bug
          Components: DataSet API, Python API
    Affects Versions: 1.0.3
            Reporter: Shahin Azad


This function definition:
```
    def map(self, value):
        if isinstance(value, (tuple, list)):
            return "(" + b", ".join([self.map(x) for x in value]) + ")"
        else:
            return str(value)
```
in `/resources/python/flink/plan/DataSet.py` will raise an exception since implicit type conversion between `String` to `Bytes` is not possible. User will get following error if he tries to run the wordcount example from the documentation:
```
File "/tmp/flink-dist-cache-fb3d569b-c811-4065-acef-32267183aa15/f1b0eb6c0a099b22760f7300760e6e80/flink/flink/plan/Da
taSet.py", line 38, in map
    return "(" + b", ".join([self.map(x) for x in value]) + ")"
TypeError: sequence item 0: expected a bytes-like object, str found
        at org.apache.flink.python.api.streaming.data.PythonStreamer.streamBufferWithoutGroups(PythonStreamer.java:269)
        at org.apache.flink.python.api.functions.PythonMapPartition.mapPartition(PythonMapPartition.java:54)
        at org.apache.flink.runtime.operators.MapPartitionDriver.run(MapPartitionDriver.java:98)
        at org.apache.flink.runtime.operators.BatchTask.run(BatchTask.java:480)
        at org.apache.flink.runtime.operators.BatchTask.invoke(BatchTask.java:345)
        at org.apache.flink.runtime.taskmanager.Task.run(Task.java:559)
        at java.lang.Thread.run(Thread.java:745)
```
To resolve this issue it's enough to change `b", "` to a normal string by removing Byte conversion notation. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)