Coming soon: We’re working on a brand new, revamped Community experience. Want to receive updates? Sign up now!

0 votes
  • Creating a very minimalist Python package/module with a UDF :
import pyspark.sql.functions as func
import pyspark.sql.types as pysparktypes

def 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'))
  • Processing the dataset with a column 'category' with this package will fail.
import udf_test
df_transfo = udf_test.transfo_dataset(df)
  • Error Message (first line)
Py4JJavaError: An error occurred while calling o64.showString.

The same error is happening if we try to export the dataset

  • Current solution

Copy paste the code in the Recipe/Notebook and call directly the function

df_transfo = transfo_dataset(df)

I understand from this answer 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.

closed with the note: answered. Bad version of Spark
closed by
1,337 questions
1,362 answers
11,912 users

©Dataiku 2012-2018 - Privacy Policy