saffovski
New Contributor II

Hi, I am facing the exact same error. The method that I'm calling in the foreachBatch is just a very simple print statement that test whether the method is called or no, and the print is not printed out. Here's a code snippet:

def debug_batch(batch_df, batch_id):
    print(f"Batch {batch_id} started, row count = {batch_df.count()}")

query = (
    df.writeStream
        .option("checkpointLocation", checkpoint_path)
        .trigger(availableNow=True)
        .foreachBatch(debug_batch)
        .start()
        .awaitTermination()
)