def get_sparkSession(myApp):
conf = (SparkConf().setMaster("yarn").setAppName(myApp)
.set("spark.executor.memory", "2g")
.set('hive.exec.dynamic.partition', 'true')
.set('spark.sql.autoBroadcastJoinThreshold','-1')
.set('hive.exec.dynamic.partition.mode', 'nostrick')
.set('hive.exec.max.dynamic.partitions', '100000')
.set('hive.exec.max.dynamic.partitions.pernode', '100000')
.set("spark.port.maxRetries", "100")
)
spark = SparkSession.builder.config(conf=conf).enableHiveSupport().getOrCreate()
# SparkSession 是 Spark SQL 的入口,使用 Dataset 或者 Datafram 编写 Spark SQL 应用的时候,第一个要创建的对象就是 SparkSession。
# Builder 是 SparkSession 的构造器。 通过 Builder, 可以添加各种配置。
return spark
参数参考: http://spark.apachecn.org/#/docs/20