[
https://issues.apache.org/jira/browse/SPARK-21096?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Hyukjin Kwon resolved SPARK-21096.
----------------------------------
Resolution: Not A Problem
That's not an issue in Spark but maybe cloudpickle or Python.
I wonder how we could avoid this though
{code}
>>> class A():
... def __init__(self):
... self.a = "a"
... self.b = "b"
...
>>> obj = A()
>>> def test(): obj.b
...
>>> b = "a"
>>> def test1(): b
...
>>> import dis
>>> dis.dis(test)
1 0 LOAD_GLOBAL 0 (obj)
3 LOAD_ATTR 1 (b)
6 POP_TOP
7 LOAD_CONST 0 (None)
10 RETURN_VALUE
>>> dis.dis(test1)
1 0 LOAD_GLOBAL 0 (b)
3 POP_TOP
4 LOAD_CONST 0 (None)
7 RETURN_VALUE
{code}
> Pickle error when passing a member variable to Spark executors
> --------------------------------------------------------------
>
> Key: SPARK-21096
> URL: https://issues.apache.org/jira/browse/SPARK-21096
> Project: Spark
> Issue Type: Bug
> Components: Spark Core
> Affects Versions: 2.1.1
> Reporter: Irina Truong
>
> There is a pickle error when submitting a spark job that references a member
> variable in a lambda, even when the member variable is a simple type that
> should be serializable.
> Here is a minimal example:
> https://gist.github.com/j-bennet/8390c6d9a81854696f1a9b42a4ea8278
> In the gist above, this method will throw an exception:
> {quote}
> def build_fail(self):
> processed = self.rdd.map(lambda row: process_row(row, self.multiplier))
> return processed.collect()
> {quote}
> While this method will run just fine:
> {quote}
> def build_ok(self):
> mult = self.multiplier
> processed = self.rdd.map(lambda row: process_row(row, mult))
> return processed.collect()
> {quote}
> In this example, {{self.multiplier}} is just an int. However, passing it into
> a lambda throws a pickle error, because it is trying to pickle the whole
> {{self}}, and that contains {{sc}}.
> If this is the expected behavior, then why should re-assigning
> {{self.multiplier}} to a variable make a difference?
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]