Skip to content

Instantly share code, notes, and snippets.

@ufo22940268
Created December 2, 2017 23:44
Show Gist options
  • Save ufo22940268/44d72cb58a9627bdf9a40c78246c4ed3 to your computer and use it in GitHub Desktop.
Save ufo22940268/44d72cb58a9627bdf9a40c78246c4ed3 to your computer and use it in GitHub Desktop.
import org.apache.spark.sql.{SparkSession, functions}
object SparkTest {
def main(args: Array[String]): Unit = {
test
}
private def test = {
val spark = SparkSession.builder
.master("local")
.appName("my app")
.enableHiveSupport().getOrCreate()
/**
* 能正常执行
*/
spark.read.textFile("/Users/cc/test.py").show()
/**
* 在 intellij 上直接运行打印不出表, 但是通过package => spark-submit 方式运行,就能打印出表
*/
spark.sql("show tables").show()
spark.stop()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment