How to run a Spark test from IntelliJ (or other IDE)

时光总嘲笑我的痴心妄想 提交于 2019-12-12 04:22:37

问题


I am trying to create a Test for some Spark code. The following code fails when getting a SparkSession object. NOTE: The test runs fine when running from the cli: gradle my_module:build

@Test
def myTest(): Unit = {
  val spark = SparkSession.builder().master("local[2]").getOrCreate()
  ...
}

Error:

java.lang.IllegalArgumentException: Can't get Kerberos realm
...
Caused by: java.lang.reflect.InvocationTargetException
...
Caused by: KrbException: Cannot locate default realm

My set-up: IntelliJ + Gradle + Mac OS

Questions:

  • How do I run a Spark Test from within IntelliJ?
  • Why is Spark looking for Kerberos at all when running 'local'

回答1:


By your code you need to run Spark from JUnit, not specifically from IntelliJ, you can try something like https://github.com/sleberknight/sparkjava-testing



来源:https://stackoverflow.com/questions/43398058/how-to-run-a-spark-test-from-intellij-or-other-ide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!