Registered users can ask their own questions, contribute to discussions, and be part of the Community!
import pyspark.sql.functions as funcimport pyspark.sql.types as pysparktypesdef test_func(x): return 'test'def transfo_dataset(df): test_udf = func.udf(test_func, pysparktypes.StringType()) return df.withColumn("new_col", test_udf('category'))
import udf_testdf_transfo = udf_test.transfo_dataset(df)df_transfo.show()
Py4JJavaError: An error occurred while calling o64.showString.
The same error is happening if we try to export the dataset
Copy paste the code in the Recipe/Notebook and call directly the function
df_transfo = transfo_dataset(df)df_transfo.show()
I understand from this answer https://answers.dataiku.com/408/spark-packages-with-dss#a410 that the code for the UDF should be available for the executors.
But in this case, it feels like the python package environment is limited. The same code is working inside a recipe but failed in a package.
This is a problem specific to UDF in this case. If I remove the UDF the package is working well.
I tried to create a small reproducible example. I can give more details if needed.
This is apparently due to our version of Spark.