pickle.PicklingError: Cannot pickle files that are not opened for reading

白昼怎懂夜的黑 提交于 2019-12-05 11:48:31

I found out the issue.I was using a dictionary in the Map function. The reason it was failing: worker nodes couldn't access the dictionary which I was passing in map function.

Solution :

I broadcasted the dictionary and then used it in function (Map)
sc =  SparkContext()
lookup_bc = sc.broadcast(lookup_dict)

Then in function, I took value by using this:

data = lookup_bc.value.get(key)

Hope it helps !

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!