Forum Discussion

tan_thiamhuat's avatar
tan_thiamhuat
Post Patron
1 year ago
Solved

Py4JJavaError: An error occurred while calling o84455.csv.

Py4JJavaError: An error occurred while calling o84455.csv. : org.apache.spark.SparkException: Job aborted due to stage failure: Serialized task 661:0 was 145766442 bytes, which exceeds max allowed: s...
  • burakkaragoz's avatar
    burakkaragoz
    1 year ago

    Thanks for clarifying! So you’re using coalesce(1) because you need a single CSV file, then you move it to SFTP. That makes sense.

    But keep in mind:

    • Using coalesce(1) on a big DataFrame forces all the data to one node/worker, which can cause memory issues or serialization errors—especially with large datasets like yours.
    • That’s usually why the Spark job fails or throws those message size/serialization errors.

    Possible solutions:

    1. If you must have a single file, try to:

      • Increase spark.rpc.message.maxSize even more (if you haven’t already).
      • Make sure your cluster has enough memory/resources for one node to handle the whole DataFrame.
      • If possible, filter or reduce your data before doing coalesce(1) to make the final file smaller.
    2. Alternative approach (if you keep hitting errors):

      • Write the CSV without coalesce(1) (so you get multiple part files).
      • Combine those part files into one CSV outside of Spark (with a shell script, Python, etc.) before SFTP transfer.

    Let me know if you still get errors or want help with merging the part files after export!