I'm trying to use a pandas udf on a Jupyter notebook on AWS EMR to no avail. First I tried to use a function that I did, but I couldn't get it to work, so I tried some examples of answers to other questions I found here, but I still couldn't get it to work. I tried this code:
from pyspark.sql.functions import pandas_udf, PandasUDFType
from pyspark.sql.types import *
import pyspark.sql.functions as F
import pyarrow
df = spark.createDataFrame([
(1, "A", "X1"),
(2, "B", "X2"),
(3, "B", "X3"),
(1, "B", "X3"),
(2, "C", "X2"),
(3, "C", "X2"),
(1, "C", "X1"),
(1, "B", "X1"),
], ["id", "type", "code"])
schema = StructType([
StructField("code", StringType()),
])
@F.pandas_udf(schema, F.PandasUDFType.GROUPED_MAP)
def dummy_udaf(pdf):
pdf = pdf[['code']]
return pdf
df.groupBy('type').apply(dummy_udaf).show()
And I get this error:
Caused by: java.lang.SecurityException: class "io.netty.buffer.ArrowBuf"'s signer information does not match signer information of other classes in the same package
I tried without the import pyarrow and I get the same error. I also used other codes from answers about this topic and the result was the same.
In the bootstrap shell script I have a pip install line as follows:
sudo python3 -m pip install pandas==0.24.2 pyarrow==0.14.1
I've tried with pyarrow 0.15.1, but nothing changed. Dou you have any idea what is causing this error? Thank you!