Spark asynchronous job fails with error

后端 未结 1 1732
时光说笑
时光说笑 2021-01-17 06:39

I\'m writing code for spark in java. When I use foreachAsync spark fails and gives me java.lang.IllegalStateException: Cannot call methods on a stopped Sp

相关标签:
1条回答
  • 2021-01-17 06:53

    It's because foreachAsync returns a Future object and when you leave a function, the spark context is closed (because it's created locally).

    If you call get() on foreachAsync() then main thread will wait for the Future to complete.

    0 讨论(0)
提交回复
热议问题